/**
* Calculates the tip needed to be paid
* Sejin Park
* 09/16/17
*/
import java.util.*;
public class TipCalculator {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
boolean keepGoing = true;
double bill = 0;
double tipPercent = 0;
boolean tryAgain = false;
while(keepGoing){ //loops the whole thing
System.out.println("Enter the bill: ");
bill = sc.nextDouble();
System.out.println("Enter tip percentage: ");
tipPercent = sc.nextDouble();
double tip = bill * (tipPercent / 100);
bill = bill + tip; //total bill
System.out.println("Tip = " + tip);
System.out.println("Total bill = " + bill);
System.out.println("Between how many people is this bill being split?");
int people = sc.nextInt();
bill = bill/(double)people; //because people is an int
System.out.println("The bill for each person is: " + bill);
System.out.println("Create another bill?");
String createAnother = sc.next();
if(createAnother.equals("no"))
keepGoing = false;
}
}
}
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.