/**
* @author (Adam Kovacs)
* @version (1.0)
*/
import java.util.Scanner;
public class TipCalculo
{
public static void main(String[] args)
{ while (true) {
Scanner s = new Scanner(System.in);
System.out.print("Please enter meal amount"); //here the user enters the amount of the meal
double nextInt = s.nextInt();
System.out.print("enter the percent you would like to tip"); //here the user adds the percent they want to tip
double percent = s.nextInt();
double tip = (nextInt * (percent/100));
double totalcost = ((tip) + nextInt);
System.out.println("Total cost: " + totalcost);
System.out.println("");
System.out.println("enter how many people you would like to share the bill with"); //user enters amount of people to slpit bill with
int numberpeople = s.nextInt();
double perperson = (totalcost/numberpeople);
System.out.println("For " +numberpeople+ " people each person should pay: " +perperson);
System.out.println("To calculate another tip, press 1, or press 0 to end the program");
int last = s.nextInt();
if (last != 1) {
break;
}
}
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.