/**
* Write a description of class tip here.
*Calculates tip
* @author Rahul Khullar)
* @version (9/18/17)
*/
import java.util.*;
public class tip
{
public tip()
{
int restarter = 1;
while (restarter == 1){
// initialise instance variables
System.out.println("How much does your bill cost?");
Scanner scan = new Scanner(System.in);
double bill = scan.nextDouble();
System.out.println("Enter the percentage of your tip");
double tip1 = scan.nextInt();
double tip2 = bill * (tip1 / 100);
double tip3 = tip2 * bill;
double total = bill + tip2;
System.out.println("Tip: $" + tip2);
System.out.println("total: $" + total);
System.out.println("How many people do you want to split the bill among");
int ppl = scan.nextInt();
double amtppl = total / ppl;
System.out.println("Each person should pay: $" + amtppl);
System.out.println("If you want to try again press 1, if not press anything else");
int decider = scan.nextInt();
if (decider == 1){
restarter = 1;
}
else {
restarter = 2;
}
}
}
}
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.