1. Member
Join Date
Jan 2014
Posts
3
Rep Power
0

## Calculation help =(

Java Code:
```static void dispOrders() {

System.out.println("");

System.out.print("How many orders (max 10) : ");

orders = scInput.nextInt();

System.out

.println("-----------------------------------------------");

if (orders < 11) {

for (int i = 0; i < orders; i++) {

if (String.valueOf(order).length() < 2) {

System.out.println("Order (" + adorder + ")");

} else if (String.valueOf(order).length() > 3) {

System.out.println("Order (" + adorder + ")");

} else {

System.out.println("Order (" + adorder + ")");

}

if (String.valueOf(order).length() < 2) {

curorder = "P000" + Integer.toString(order);

System.out.println("Order number: " + curorder);

} else if (String.valueOf(order).length() > 3) {

curorder = "P00" + Integer.toString(order);

System.out.println("Order number: " + curorder);

} else {

curorder = "P0" + Integer.toString(order);

System.out.println("Order number: " + curorder);

}

System.out.print("Enter customer name: ");

customerName = scInput.next();

System.out

.print("Enter number of carrots(@\$0.40cts): ");

carrots = scInput.nextInt();

while (carrots > 1000 || carrots < 0) {

System.out.print("Thats an invalid number!");

System.out

.print("Enter number of carrots(@\$0.40cts): ");

carrots = scInput.nextInt();

}

totalcarrots += carrots;

System.out.print("Enter number of onions(@\$0.45cts): ");

onions = scInput.nextInt();

while (onions > 1000 || onions < 0) {

System.out.println("Thats an invalid number!");

System.out

.print("Enter number of onions(@\$0.45cts): ");

onions = scInput.nextInt();

}

totalonions += onions;

System.out.print("Enter number of potatos(@\$0.35cts): ");

potatos = scInput.nextInt();

while (potatos > 1000 || potatos < 0) {

System.out.println("Thats an invalid number!");

System.out

.print("Enter number of potatos(@\$0.35cts): ");

potatos = scInput.nextInt();

}

totalpotatos += potatos;

System.out

.print("Enter number of tomatos(@\$0.50): ");

tomatos = scInput.nextInt();

while (tomatos > 1000 || tomatos < 0) {

System.out.println("Thats an invalid number!");

System.out

.print("Enter number of tomatos(@\$0.50): ");

tomatos = scInput.nextInt();

}

totaltomatos += tomatos;

carrotsprice = fmt3.format(0.40 * carrots);

onionsprice = fmt3.format(0.45 * onions);

potatosprice = fmt3.format(0.35 * potatos);

tomatosprice = fmt3.format(0.50 * tomatos);

totalprice = fmt3.format((0.40 * carrots)

+ (0.45 * onions)

+ (0.35 * potatos) + (0.50 * tomatos));

String[] cost = { curorder, customerName, carrotsprice,

onionsprice,

Integer[] veggies = { carrots,onions,potatos,tomatos };

order += 1;

tcarrots += 0.40 * carrots;

tonions += 0.45 * onions;

tpotatos += 0.35 * potatos;

ttomatos += 0.50 * tomatos;

ttotal += (0.40 * carrots) + (0.45 * onions)

+ (0.35 * potatos)

+ (0.50 * tomatos);

}

}

}

static void editInfo() {
for (int i = 0 ; i < prices.size(); i++) {

System.out.println(prices.get(i)[7] + ") " + prices.get(i)[1] + " "

+ prices.get(i)[0]);

}
System.out.print(">");

i = scInput.nextInt();

System.out.println("Customer name: " + prices.get(i-1)[1]);

System.out.println("Order number : " + prices.get(i-1)[0]);

System.out.println("Number of carrots: "+veges.get(i-1)[0]);

System.out.print("Do you want to change?(y/n): ");

System.out.print("Enter the number of carrots: ");
veges.get(i-1)[0] = scInput.nextInt();
while (veges.get(i-1)[0] > 1000 || veges.get(i-1)[0] < 0) {

System.out.println("Thats an invalid number!");
System.out.print("Enter the number of carrots: ");
veges.get(i-1)[0] = scInput.nextInt();}

System.out.println("Choice is invalid");
System.out.print("Do you want to change?(y/n): ");
System.out.print("Enter the number of carrots: ");
veges.get(i-1)[0] = scInput.nextInt();
while (veges.get(i-1)[0] > 1000 || veges.get(i-1)[0] < 0) {

System.out.println("Thats an invalid number!");
System.out.print("Enter the number of carrots: ");
veges.get(i-1)[0] = scInput.nextInt();}
}

}

}
System.out.println("Number of onions : "+veges.get(i-1)[1]);

System.out.print("Do you want to change?(y/n): ");
System.out.print("Enter the number of onions: ");
veges.get(i-1)[1] = scInput.nextInt();
while (veges.get(i-1)[1] > 1000 || veges.get(i-1)[1] < 0) {

System.out.println("Thats an invalid number!");
System.out.print("Enter the number of onions: ");
veges.get(i-1)[1] = scInput.nextInt();}
System.out.println("Choice is invalid");
System.out.print("Do you want to change?(y/n): ");
System.out.print("Enter the number of onions: ");
veges.get(i-1)[1] = scInput.nextInt();
while (veges.get(i-1)[1] > 1000 || veges.get(i-1)[1] < 0) {

System.out.println("Thats an invalid number!");
System.out.print("Enter the number of onions: ");
veges.get(i-1)[1] = scInput.nextInt();}
}
}
}
System.out.println("Number of potatos : "+veges.get(i-1)[2]);
System.out.print("Do you want to change?(y/n): ");
System.out.print("Enter the number of potatos: ");
veges.get(i-1)[2] = scInput.nextInt();
while (veges.get(i-1)[2] > 1000 || veges.get(i-1)[2] < 0) {

System.out.println("Thats an invalid number!");
System.out.print("Enter the number of potatos: ");
veges.get(i-1)[2] = scInput.nextInt();}
System.out.println("Choice is invalid");
System.out.print("Do you want to change?(y/n): ");
System.out.print("Enter the number of potatos: ");
veges.get(i-1)[2] = scInput.nextInt();
while (veges.get(i-1)[2] > 1000 || veges.get(i-1)[2] < 0) {
System.out.println("Thats an invalid number!");
System.out.print("Enter the number of potatos: ");
veges.get(i-1)[2] = scInput.nextInt();}
}}
}
System.out.println("Number of tomatos : "+veges.get(i-1)[3]);
System.out.print("Do you want to change?(y/n): ");
System.out.print("Enter the number of tomatos: ");
veges.get(i-1)[3] = scInput.nextInt();
while (veges.get(i-1)[3] > 1000 || veges.get(i-1)[3] < 0) {

System.out.println("Thats an invalid number!");
System.out.print("Enter the number of tomatos: ");
veges.get(i-1)[3] = scInput.nextInt();}

System.out.println("Choice is invalid");
System.out.print("Do you want to change?(y/n): ");
System.out.print("Enter the number of tomatos: ");
veges.get(i-1)[3] = scInput.nextInt();
while (veges.get(i-1)[3] > 1000 || veges.get(i-1)[3] < 0) {

System.out.println("Thats an invalid number!");
System.out.print("Enter the number of tomatos: ");
veges.get(i-1)[3] = scInput.nextInt();
}

carrotsprice = fmt3.format(0.40 * veges.get(i-1)[0]);

onionsprice = fmt3.format(0.45 * veges.get(i-1)[1]);

potatosprice = fmt3.format(0.35 * veges.get(i-1)[2]);

tomatosprice = fmt3.format(0.50 * veges.get(i-1)[3]);

totalprice = fmt3.format((0.40 * veges.get(i-1)[0])

+ (0.45 * veges.get(i-1)[1])

+ (0.35 * veges.get(i-1)[2]) + (0.50 * veges.get(i-1)[3]));

String[] cost = { curorder, customerName, carrotsprice,

onionsprice,

Integer[] veggies = { carrots,onions,potatos,tomatos };

order += 1;

tcarrots += 0.40 * veges.get(i-1)[0];

tonions += 0.45 * veges.get(i-1)[1];

tpotatos += 0.35 * veges.get(i-1)[2];

ttomatos += 0.50 * veges.get(i-1)[3];

ttotal += (0.40 * veges.get(i-1)[0]) + (0.45 * veges.get(i-1)[1])

+ (0.35 * veges.get(i-1)[2])

+ (0.50 * veges.get(i-1)[3]);```
I want to show my prices for each orders after i edit, but what is shows is my prices before editing. How do i show my prices for the orders after editing?

2. ## Re: Calculation help =(

Can you post the program's current output and add some comments showing what the output should be?

show my prices for the orders after editing
Where does the program do the editing? I don't see any comments that say where it is done.
What is the problem moving the print out to after the editing is done?

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•