/**
* Write a description of class TipCalculator here.
*
* @author (your name)
* @version (a version number or a date)
*/
import java.util.*;
public class TipCalculator
{
public static void main(String[] args) {
boolean again = true;
while(again){
Scanner scan = new Scanner(System.in);
System.out.println("How much did the bill cost (no $)");
double ogvalue = scan.nextDouble();
System.out.println("How much would you like to tip (no %)");
double tippercent = scan.nextDouble();
double tip = ogvalue * (tippercent /100);
double total = tip + ogvalue;
System.out.println("You would tip" + tip + "and the total would be " + total);
System.out.println("If you would like to divide this tip among multiple people, press 1, 2 to cancel");
int mult = scan.nextInt();
if( mult == 1){
System.out.println("How many people would you like to divide the bill by ? ");
double amount = scan.nextDouble();
double fin = total / amount;
System.out.println("Each person has to pay " + fin);
}
System.out.println("If you would like to find another tip, press 1, 2 to cancel");
int another = scan.nextInt();
if(another == 1)
again = true;
if(another == 2){
again = false;
System.out.println("Thank you for using my tip calculator");
}
}
}
}
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.