This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
I'm trying to make a menu for a homework assignment for my computer science course. I thought I had everything down, but I keep getting errors that I can't seem to fix. Also I can only use up to Java 1.4.2, so I can't use Scanner. Here is the code:
UPDATED CODE
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class JavaBurger
{
static ArrayList MenuItems = new ArrayList();
public static void main(String[] args)
{
InputStreamReader inp = null;
BufferedReader input = null;
int nOption = 0;
double price = 0;
double amount;
double amount1 = 0;
double amount2 = 0;
double amount3 = 0;
double amount4 = 0;
double amount5 = 0;
double amount6 = 0;
double amount7 = 0;
double amount8 = 0;
double amount9 = 0;
double amount10 = 0;
amount = (amount1 + amount2 + amount3 + amount4 + amount5 + amount6 + amount7 + amount8 + amount9 + amount10);
try
{
inp = new InputStreamReader(System.in);
input = new BufferedReader(inp);
while(true)
{
System.out.println("Choose a Menu Option");
System.out.println("1. Burger - 13.49");
System.out.println("2. Pasta - 16.79");
System.out.println("3. Salad - 13.49");
System.out.println("4. Salmon - 18.99");
System.out.println("5. Chicken - 16.99");
System.out.println("6. Nachos - 13.99");
System.out.println("7. Soup - 6.99");
System.out.println("8. Fajitas - 18.49");
System.out.println("9. Ribs - 23.99");
System.out.println("10. Calamari-9.99");
System.out.println("\nChoose an option(1-10) >> ");
System.out.println("Subtotal: $" + amount);
System.out.println("Total: $" + (amount * 1.13));
nOption = Integer.parseInt(input.readLine());
switch(nOption)
{
case 1:
Burger(input);
break;
case 2:
Pasta(input);
break;
case 3:
Salad(input);
break;
case 4:
Salmon(input);
break;
case 5:
Chicken(input);
break;
case 6:
Nachos(input);
break;
case 7:
Soup(input);
break;
case 8:
Fajitas(input);
break;
case 9:
Ribs(input);
break;
case 10:
Calamari(input);
break;
}
}
}
catch(Exception exp)
{
}
}
public static void Burger(BufferedReader input) throws IOException
{
while(true)
{
System.out.println("How many Burgers would you like? ");
int a = Integer.parseInt(input.readLine());
int aa = a.nextInt();
double aaa = Math.pow(1 + a, aa);
amount1 = (aaa * 13.49);
break;
}
}
public static void Pasta(BufferedReader input) throws IOException
{
while(true)
{
System.out.println("How many orders of Pasta would you like? ");
int b = Integer.parseInt(input.readLine());
int bb = b.nextInt();
double bbb = Math.pow(1 + b, bb);
amount2 = (bbb * 16.79);
break;
}
} public static void Salad(BufferedReader input) throws IOException
{
while(true)
{
System.out.println("How many Salads would you like? ");
int c = Integer.parseInt(input.readLine());
int cc = c.nextInt();
double ccc = Math.pow(1 + c, cc);
amount3 = (ccc * 13.49);
break;
}
} public static void Salmon(BufferedReader input) throws IOException
{
while(true)
{
System.out.println("How many orders of Salmon would you like? ");
int d = Integer.parseInt(input.readLine());
int dd = d.nextInt();
double ddd = Math.pow(1 + d, dd);
amount4 = (ddd * 18.99);
break;
}
} public static void Chicken(BufferedReader input) throws IOException
{
while(true)
{
System.out.println("How many orders of Chicken would you like? ");
int e = Integer.parseInt(input.readLine());
int ee = e.nextInt();
double eee = Math.pow(1 + e, ee);
amount5 = (eee * 16.99);
break;
}
} public static void Nachos(BufferedReader input) throws IOException
{
while(true)
{
System.out.println("How many orders of Nachos would you like? ");
int f = Integer.parseInt(input.readLine());
int ff = f.nextInt();
double fff = Math.pow(1 + f, ff);
amount6 = (fff * 13.99);
break;
}
} public static void Soup(BufferedReader input) throws IOException
{
while(true)
{
System.out.println("How many orders of Soup would you like? ");
int g = Integer.parseInt(input.readLine());
int gg = g.nextInt();
double ggg = Math.pow(1 + g, gg);
amount7 = (ggg * 6.99);
break;
}
} public static void Fajitas(BufferedReader input) throws IOException
{
while(true)
{
System.out.println("How many orders of 2 Fajitas would you like? ");
int h = Integer.parseInt(input.readLine());
int hh = h.nextInt();
double hhh = Math.pow(1 + h, hh);
amount8 = (hhh * 18.49);
break;
}
} public static void Ribs(BufferedReader input) throws IOException
{
while(true)
{
System.out.println("How many racks of Ribs would you like? ");
int i = Integer.parseInt(input.readLine());
int ii = i.nextInt();
double iii = Math.pow(1 + i, ii);
amount9 = (iii * 23.99);
break;
}
} public static void Calamari(BufferedReader input) throws IOException
{
while(true)
{
System.out.println("How many orders of Calamari would you like? ");
int j = Integer.parseInt(input.readLine());
int jj = j.nextInt();
double jjj = Math.pow(1 + j, jj);
amount10 = (jjj * 9.99);
break;
}
}
}
UPDATED ERRORS:
C:\Java\bin>javac JavaBurger.java
JavaBurger.java:98: error: int cannot be dereferenced
int aa = a.nextInt();
^
JavaBurger.java:100: error: cannot find symbol
amount1 = (aaa * 13.49);
^
symbol: variable amount1
location: class JavaBurger
JavaBurger.java:114: error: int cannot be dereferenced
int bb = b.nextInt();
^
JavaBurger.java:116: error: cannot find symbol
amount2 = (bbb * 16.79);
^
symbol: variable amount2
location: class JavaBurger
JavaBurger.java:128: error: int cannot be dereferenced
int cc = c.nextInt();
^
JavaBurger.java:130: error: cannot find symbol
amount3 = (ccc * 13.49);
^
symbol: variable amount3
location: class JavaBurger
JavaBurger.java:143: error: int cannot be dereferenced
int dd = d.nextInt();
^
JavaBurger.java:145: error: cannot find symbol
amount4 = (ddd * 18.99);
^
symbol: variable amount4
location: class JavaBurger
JavaBurger.java:158: error: int cannot be dereferenced
int ee = e.nextInt();
^
JavaBurger.java:160: error: cannot find symbol
amount5 = (eee * 16.99);
^
symbol: variable amount5
location: class JavaBurger
JavaBurger.java:173: error: int cannot be dereferenced
int ff = f.nextInt();
^
JavaBurger.java:175: error: cannot find symbol
amount6 = (fff * 13.99);
^
symbol: variable amount6
location: class JavaBurger
JavaBurger.java:187: error: int cannot be dereferenced
int gg = g.nextInt();
^
JavaBurger.java:189: error: cannot find symbol
amount7 = (ggg * 6.99);
^
symbol: variable amount7
location: class JavaBurger
JavaBurger.java:202: error: int cannot be dereferenced
int hh = h.nextInt();
^
JavaBurger.java:204: error: cannot find symbol
amount8 = (hhh * 18.49);
^
symbol: variable amount8
location: class JavaBurger
JavaBurger.java:217: error: int cannot be dereferenced
int ii = i.nextInt();
^
JavaBurger.java:219: error: cannot find symbol
amount9 = (iii * 23.99);
^
symbol: variable amount9
location: class JavaBurger
JavaBurger.java:232: error: int cannot be dereferenced
int jj = j.nextInt();
^
JavaBurger.java:234: error: cannot find symbol
amount10 = (jjj * 9.99);
^
symbol: variable amount10
location: class JavaBurger
20 errors
Errors:
You are using null variables:
double amount;
double amount1;
None of these are initialized with any value. They are all null. You can inline the definition and give them all proper values.
double amount = 0, amount1 = 2, amount3 = 5;//etc
You are defining amount twice:
double amount;
double amount = (amount1 + amount2 + amount3 + amount4 + amount5 + amoun
t6 + amount7 + amount8 + amount9 + amount10);
Remove the double from the second one:
amount = (amount1 + amount2 + amount3 + amount4 + amount5 + amoun
t6 + amount7 + amount8 + amount9 + amount10);
Next, you always need to cast from String to Double.
(input.readLine() * 18.49); // should be
Double.parseDouble(input.readLine()) * 18.49;
The readLine() method does not return a numeric value.
Try declaring your amounts as global variables outside the main method. What the cannot find symbol error means is the program can't access the variables you're telling it to access.
Also, you might want to try updating the total amount after you update the original amounts in each method.
You try to declare amount twice:
double amount;
double amount1;
[...]
double amount = (amount1 + amount[...]
remove the double from the last line to make it just an assignment.
amount1 = (input.readInt * 13.49);
BufferedReader has no readInt method. You might want to replace this with
amount1 = (Integer.parseInt(input.readLine) * 13.49);
Related
So I'm trying to write a program that stimulates the rise and fall of the Stock market 5 times.The user inputs a value to create a new Stock Market Object then with the value from the user, the stock market either is a bust(decrease) or a boom( increase). The issue I'm having is passing the value to each if statement with the change within the loop.When I run the program, It uses the same value I entered instead of using the value that was created after calling boom or bust. I'm thinking I should create a value outside the loop that holds it but I'm not sure how to do that with the user input.
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter a Starting Market Value:");
double mv = in.nextDouble();
StockMarket u = new StockMarket(mv);
for (int i = 0; i < 5; i++) {
System.out.println("Boom (1) or Bust(2)? ");
int t = in.nextInt();
if (t == 1) {
System.out.println("Enter a percentage of increase as a decimal ( eg .5 ):");
double r = in.nextDouble();
if (t == 1) {
double e = u.boom(r);
System.out.println("The Stock Market is now at: " + e);
}
} else if (t == 2) {
System.out.println("Enter number of points lost:");
double l = in.nextDouble();
if (t == 2) {
double f = u.bust(l);
System.out.println("The Stock Market is now at: " + f);
}
}
}
}
}
Below is the class
public class StockMarket {
//Instance Variable Points
private double Points;
// Default no Argument Constructor
public StockMarket(){
this(0.0);
}
// Constructor #2
public StockMarket(double Points){
this.Points = Points;
}
//
public double getPoint(){
return Points;
}
public double boom(double x){
x = Points * (1 + x);
return x;
}
public double bust( double h){
h = Points - h;
return h;
}
}
I want to start by saying that I'm a newby in Java, and it's also my first time asking something on this site. After 3 days trying to figure out how to break this small program in methods, I haven't been able to do so. could anyone help me with it ?
I've been reading and it looks like I'm violating the single responsibility principle. Any opinions would be more than welcome.
public class RateSystem {
double employeeSalary;
public int salaryRate(String employeePosition) {
if (employeePosition.equalsIgnoreCase("1")) {
return 40;
} else if (employeePosition.equalsIgnoreCase("2")) {
return 30;
} else
employeePosition.equalsIgnoreCase("3");
return 50;
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Employee position please...");
System.out.println("Press 1 for IT " + "\n" + "Press 2 for Tech" +
"\n" + "Press 3 for engineer");
String ePosition = input.nextLine();
RateSystem raul = new RateSystem();
int getPay = raul.salaryRate(ePosition);
System.out.println("How many hours did he work for the week?...");
int weekHours = input.nextInt();
int totalPay = 0;
if (weekHours <= 40) {
totalPay = getPay * weekHours;
System.out.println("Employee salary is " + totalPay);
} else {
int overTimeHours = weekHours - 40;
int extra$$PerOverTime = overTimeHours * getPay +(overTimeHours * getPay/2);
totalPay = getPay * (weekHours - overTimeHours);
System.out.println("The employee accumulated 40 hours equivalent to $"+
totalPay + " plus $" + extra$$PerOverTime + " overtime hours, a total of $"+(extra$$PerOverTime + totalPay));
}
}
}
If we are looking at main(), It does multiple tasks:
Receive user input
Calculate total pay and possible other finance information
Print the results
How's that for starters
I see followings could be added.
1) Salaries are created for Employees so why don't you create and Employee class and encapsulate details inside it like "employeePosition". So you can add more things later and having setters inside it you will get the chance of changing setter logics for employees.
2) You can create a Calculator class and create methods accepting single Employee or a List of Employees and calculate their Salary Rates.
3) You also can add a Printing related class. So you can produce different printing for single or List of Employees or may be like a tabular format.
I have identified following methods in your code.
1) showMainMenu --> responsible to show menu to the user
2) readMenuSelection --> here you will read whatever user has selected in the main menu. It should be read in int value rather than string.
3) For each Selection from menu there will be separate methods such as payForIT(), payForTech() and payForEngineer()
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Employee position please...");
System.out.println("Press 1 for IT " + "\n" + "Press 2 for Tech" + "\n" + "Press 3 for engineer");
String position = input.nextLine();
RateSystem rateSystem = new RateSystem();
rateSystem.setEmployeePosition(position);
System.out.println("How many hours did he work for the week?...");
int weekHours = input.nextInt();
rateSystem.setWeekHours(weekHours);
rateSystem.calculateSalary();
int totalPay = rateSystem.getTotalPay();
int overTime = rateSystem.getOvertime();
if (overTime > 0) {
System.out.println("The employee accumulated 40 hours equivalent to $" + totalPay + " plus $" + overTime
+ " overtime hours, a total of $" + (overTime + totalPay));
} else {
System.out.println("Employee salary is " + totalPay);
}
}
}
public class RateSystem {
private final int STANDARD_WORK = 40;
private double employeeSalary;
private int weekHours;
private Position employeePosition;
private int totalPay = 0;
private int overTime = 0;
public void setEmployeePosition(String position) {
employeePosition = Position.fromString(position);
}
public void setWeekHours(int weekHours) {
this.weekHours = weekHours;
}
public int getTotalPay() {
return totalPay;
}
public int getOvertime() {
return overTime;
}
public void calculateSalary() {
int salaryRate = employeePosition.getRate();
int workhours = (weekHours > STANDARD_WORK) ? STANDARD_WORK : weekHours;
int overTimeHours = (weekHours > STANDARD_WORK) ? (weekHours - STANDARD_WORK) : 0;
totalPay = workhours * weekHours;
overTime = (overTimeHours * salaryRate) + (overTimeHours * salaryRate / 2);
}
}
public enum Position {
IT(40), Tech(30), Engineer(50);
private int rate = 0;
Position(int r) {
rate = r;
}
public int getRate() {
return rate;
}
public static Position fromString(String position) {
switch (position) {
case "1":
return IT;
case "2":
return Tech;
case "3":
return Engineer;
}
return null;
}
}
To follow single responsibility principle you have to create method for each common task in your program. That helps do not repeat code and helps to modify code in one place.
I have created separate methods for building string and for printing string as you use it frequently in your code:
package com.stackoverflow.main;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
println("Employee position please...");
println(buildString("Press 1 for IT ", "\n", "Press 2 for Tech", "\n", "Press 3 for engineer"));
String ePosition = input.nextLine();
RateSystem raul = new RateSystem();
int getPay = raul.salaryRate(ePosition);
println("How many hours did he work for the week?...");
int weekHours = input.nextInt();
int totalPay = 0;
if (weekHours <= 40) {
totalPay = getPay * weekHours;
println(buildString("Employee salary is ", String.valueOf(totalPay)));
} else {
int overTimeHours = weekHours - 40;
int extra$$PerOverTime = overTimeHours * getPay + (overTimeHours * getPay / 2);
totalPay = getPay * (weekHours - overTimeHours);
println(buildString("The employee accumulated 40 hours equivalent to $", String.valueOf(totalPay),
" plus $", String.valueOf(extra$$PerOverTime), " overtime hours, a total of $",
String.valueOf((extra$$PerOverTime + totalPay))));
}
}
private static String buildString(String... strings) {
StringBuilder builder = new StringBuilder();
for (String string : strings) {
builder.append(string);
}
return builder.toString();
}
private static void println(String s) {
System.out.println(s);
}
}
And class RateSystem:
package com.stackoverflow.main;
public class RateSystem {
double employeeSalary;
public int salaryRate(String employeePosition) {
if (equalsIgnoreCase(employeePosition, "1")) {
return 40;
} else if (equalsIgnoreCase(employeePosition, "2")) {
return 30;
} else if (equalsIgnoreCase(employeePosition, "3"))
return 50;
return 0;
}
private boolean equalsIgnoreCase(String arg1, String arg2) {
return arg1.equalsIgnoreCase(arg2);
}
}
I was wondering if someone could tell me
1. why, when i input weightNumber with a decimal place, weightConverted doesn't convert it to the whole number, even though I create variable for it?
2. how could i improve this "program" in any way, THANK YOU !!
here is the problem:
code:
import java.util.Scanner;
public class cofee {
public static void main (String []args){
double weightNumber = 0;
String packageType = "";
String serviceType ="";
double totalFee = 0;
double weightConverted = Math.round(weightNumber); // <- this is the problem, should i put it somewhere else?
final double LETTERCOSTP = 12.00;
final double LETTERCOSTS = 10.50;
final double BOXCOSTP = 15.75;
final double BOXCOSTS = 13.75;
final double BOXWEIGHTP = 1.25;
final double BOXWEIGHTS = 1.00;
// input
Scanner input = new Scanner(System.in);
System.out.print("Enter package type (letter/box): ");
packageType = input.nextLine().toLowerCase();
System.out.print("Enter type of service (standard/priority): ");
serviceType = input.nextLine().toLowerCase();
switch(packageType)
{
case "letter":
System.out.print("Enter the weight in ounces: ");
weightNumber = input.nextDouble();
break;
case "box":
System.out.print("Enter the weight in pounds: ");
weightNumber = input.nextDouble();
break;
default:
System.out.print("WRONG PACKAGE TYPE !!!");
}
// letter
if (packageType.equals("letter") && serviceType.equals("priority"))
{
totalFee = LETTERCOSTP;
}
if (packageType.equals("letter") && serviceType.equals("standard"))
{
totalFee = LETTERCOSTS;
}
// box
if (packageType.equals("box") && serviceType.equals("priority"))
{
totalFee = BOXCOSTP + ((weightConverted - 1.0) * BOXWEIGHTP);
}
if (packageType.equals("box") && serviceType.equals("standard"))
{
totalFee = BOXCOSTS + ((weightConverted - 1.0) * BOXWEIGHTS);
}
// display
System.out.println("The fee is € "+ totalFee + " for a package with");
System.out.println("\tType: "+packageType);
System.out.println("\tService: "+serviceType);
System.out.println("\tOunces: "+weightConverted);
}
}
The line double weightConverted = Math.round(weightNumber); will call round() with the value of weightNumber, which is 0, so it rounds 0 to... well... 0, and assigns it to weightConverted.
So I have been asked to create a program that can evaluate and print the value of...
0.1 + (0.1)^2 + (0.1)^3 . . . + (0.1)^n
using a while loop. So far I have
import java.util.Scanner;
class Power
{
public static void main(String[] args)
{
Double x;
Scanner input = new Scanner(System.in);
System.out.println("What is the maximum power of 0.1?");
x = input.nextLine;
Double n = 0.1;
Int exp = 1;
while (exp <= x)
{
Double Answer = Math.pow(n, exp); //Had to look this one up
exp++;
}
System.out.print(Answer);
}
}
I'm still having trouble trying to decode the following few Compile-time errors I am getting with this program.
Power.java:11: error: cannot find symbol
x = input.nextLine;
^
symbol: variable nextLine
location: variable input of type Scanner
Power.java:13: error: cannot find symbol
Int exp = 1;
^
symbol: class Int
location: class Power
Power.java:19: error: cannot find symbol
System.out.print(Answer);
^
symbol: variable Answer
location: class Power
Any fix? Thanks guys
~Andrew
Here you go:
import java.util.Scanner;
class Power
{
public static void main(String[] args)
{
Double x;
Scanner input = new Scanner(System.in);
System.out.println("What is the maximum power of 0.1?");
x = input.nextDouble(); //Use nextDouble to take in double
Double n = 0.1;
int exp = 1;
Double Answer = 0.0; //You have to declare Answer outside of the while loop below or else Answer will be undefined when you try to print it out in the last line.
while (exp <= x)
{
Answer = Math.pow(n, exp);
exp++;
}
System.out.print(Answer);
}
}
So, I'm trying to create a driver for my method. I apologize in advance, I know very little about what I'm talking about. What the program does, is it calculates sine, cosine, and the exponential function by means of taylor series for a number that the user inputs. The use of Math.pow and Math.fact were not allowed. My compiler isn't giving me any errors, and I'm all out of ideas at this point. In addition, the scanner doesn't seem to stop accepting input after I press enter. It continues to take numbers, but doesn't do anything else. It gives an exception when I type a letter. High possibility of ID10T error. I know that the output isn't well formatted yet, but that's because I haven't had a chance to see it yet. If someone could help me figure this out, I would be very greatful. Thanks in advance!
-An aspiring code monkey
Driver (Lab4.java)
/*
This program is being created to solve Lab 4.
*/
import java.util.*;
public class Lab4
{
public static void main(String[] args)
{
String again, more = "y";
while (more.toUpperCase().charAt(0) == 'Y')
{
Scanner keyboard = new Scanner (System.in);
System.out.println("Input X: ");
Function number = new Function();
double x = number.x();
System.out.println("x = " + x);
Function sine = new Function();
double mySin = sine.funcSine();
Function cosine = new Function();
double myCos = cosine.funcCos();
Function expo = new Function();
double myExp = expo.funcExp();
System.out.println("\t\t\t\tLibraryResult My Result");
System.out.println("\n\t\tsin(" + Function.x() + ")" + " = " + "\t\t\t" + Math.sin(Function.x()) + "\t" + mySin);
System.out.println("\n\t\tcos(" + Function.x() + ")" + " = " + "\t\t\t" + Math.cos(Function.x()) + "\t" + myCos);
System.out.println("\n\t\texp(" + Function.x() + ")" + " = " + "\t\t\t" + Math.exp(Function.x()) + "\t" + myExp);
System.out.println("\n\t\t\tDo more (Y/N) ? ");
more = keyboard.next();
String junk = keyboard.nextLine();
}
}
}
Method (Function.java)
/*
This class provides the information for the parent to use in order to solve Lab 4.
*/
import java.util.*;
public class Function
{
Scanner keyboard = new Scanner(System.in);
public static int number;
private double temp = 1;
private double last = 1;
public static double x()
{
Scanner keyboard = new Scanner(System.in);
double x = keyboard.nextDouble();
return x;
}
public static double pow(double value, double power)
{
if(power == 0)
{
return 1;
}
double result = value;
for(int i = 0; i < power -1; i++)
{
result = result * value;
}
return result;
}
public static double getFact()
{
while (number < 0)
{
number =(number * -1);
}
double factorial = 1;
if (0 == (number % 1))
{
do
{
factorial = factorial * number;
--number;
} while (number >= 1);
}
else //Stirling's Approximation
{
double e = 2.718281828459;
double part1 = Math.sqrt(2 * 3.141592653589 * number);
double part2a = (number / e);
double part2b = (pow(part2a,number));
factorial = (part1 * part2b);
}
return factorial;
}
public static double funcSine()
{
int place = 0;
double next = x()*1;
for(number = 3; number <= 30; number = number + 2)
{
next = next + ((pow((-1),place))*((pow(x(),number))/(getFact())));
place = place + 1;
}
double mySin = next * 1;
return mySin;
}
public static double funcCos()
{
int place = 0;
double next = 1;
for(number = 2; number <= 30; number = number + 2)
{
next = next + ((pow(-1,place))*((pow(x(),number))/(getFact())));
place = place + 1;
}
double myCos = next * 1;
return myCos;
}
public static double funcExp()
{
int place = 0;
double next = 1 + x();
for(number = 1; number <= 30; number++)
{
next = next + ((pow(-1,place))*((pow(x(),number))/(getFact())));
place = place + 1;
}
double myExp = next * 1;
return myExp;
}
}
Check the syntax of your while loop:
while (more.toUpperCase().charAt(0) == 'Y')
Think about when the program will ever not satisfy this expression.
Also you have multiple Scanners all over your code. ITs not clear why you need to keep reading inout over and over again.