
Hi. all
I've got a assignment to write a program that count total prices of 8 costumers.
class PriceCalculator{
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("---------");
}
}
}
Is there anyone,please help me.. Really thanks a lot
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.