Current location - Recipe Complete Network - Catering training - Java newbie asking questions! Please help me write an ordering system using for loop, while and do while loop, just write how many dollars to spend!
Java newbie asking questions! Please help me write an ordering system using for loop, while and do while loop, just write how many dollars to spend!
public?class?Test?{

public?static?void?main(String[]?args)? {

System.out.println("How much do you need to spend?") ;

Scanner?scan=new?Scanner(System.in);

double?sum=0d;

double?money=scan.nextDouble();

sum+=money;

System.out.println("This consumption: "+money+"yuan");

System.out.println("Do you want to continue consumption? (enter 1 to continue spending)");

int?isContinue=scan.nextInt();

while(true){

if(isContinue==1){

System.out.println("May I ask you to spend How much money?") ;

money=scan.nextDouble();

sum+=money;

System.out.println("This consumption: "+money+"$");

System.out.println("May I ask if you would like to continue consuming? (enter 1 for continued consumption)");

isContinue=scan.nextInt();

}else{

System.out.println("End of this consumption");

System.out.println("Total **** consumption: "+ sum+"dollars");

break;

}

}

}

}

}

}