
Hi. all
I've got a assignment to write a program that count total prices of 8 costumers.
First class
class PriceCalculator
{print("code sample");
public void method(double quantity)
{
double result;
if(quantity < 5)
{
result = 2.00*quantity;
System.out.printf(" is: %s",result);
}
if(quantity >= 6 & quantity <= 10)
{
result = 2.00*quantity*95/100;
System.out.printf(" is: %s",result);
}
if(quantity >= 11 & quantity<= 15)
{
result = 2.00*quantity*90/100;
System.out.printf(" is: %s",result);
}
if(quantity >= 16 & quantity<= 20)
{
result = 2.00*quantity*85/100;
System.out.printf(" is: %s",result);
}
if(quantity >20)
{
result = 2.00*quantity*80/100;
System.out.printf(" is: %s",result);
}
}
}
Second class
import java.util.Scanner;
public class PriceCalculatorTest{
public static void main(String[] args){
double enterQ;
System.out.println("*****WELCOMETO PRICE CALCULATOR FOR PURCHANGSING MILKS*****");
for(int counter = 1; counter <=8; ++counter)
{
Scanner input = new Scanner(System.in);
PriceCalculator m = new PriceCalculator();
System.out.printf("Enter the Name for Customer %s: ",counter);
String name = input.nextLine();
System.out.printf("Enter the number of cartons for Customer %s: ",counter);
enterQ = input.nextInt();
System.out.printf("The price for Customer - %s",name);
m.method(enterQ);
System.out.println();
System.out.println("-------------------------------------------");
}
}
}
The problem is I'm being absolutely stuck in count total prices of 8 costumers like in this picture
![alt text][1]
[1]: [IMG]http://i241.photobucket.com/albums/ff33/vanvi_1987/Untitled.jpg[/IMG]
Is there anyone,please help me..
Really thanks a lot