/**
* This class converts F to C or C to F
* @author (David Huang)
* @version (1.0)
*/
import java.util.Scanner;
public class TipCalculo
{
public static void main(String[] args)
{ while (true) {
Scanner s = new Scanner(System.in);//first scanner to input initial temp
System.out.print("Please enter meal amount");
double nextInt = s.nextInt();
System.out.print("Now enter the percent you would like to tip");
double percent = s.nextInt();
double tip = (nextInt * (percent/100));
double tipandmeal = ((tip) + nextInt);
System.out.println("Total cost: " + tipandmeal);
System.out.println("");
System.out.println("Please input how many people you would like to split the bill with");
int numberpeople = s.nextInt();
double perperson = (tipandmeal/numberpeople);
System.out.println("For " +numberpeople+ " people each person should pay: " +perperson);
System.out.println("To calculate another tip, please press 1, or press 0 to close the program");//last scanner to ask user if they want to repeat
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.