Java Tutorial

Runtime
java 21.0.12
Files
60 files · 24 KB
Runs
50 runs
Published
sessionSix/InputProblem.java587 B
package sessionSix;import java.util.Scanner;​public class InputProblem {    public static void main(String[] args) {        Scanner sc = new Scanner(System.in);​        // INPUT        double bill = Double.parseDouble(sc.nextLine());        int people = Integer.parseInt(sc.nextLine());        int tipPercent = sc.nextInt();​        // PROCESS        double tip = bill * tipPercent/100;        double perPerson = (bill + tip) / people;​        // OUTPUT        System.out.printf("Tip: %.2f%n", tip);        System.out.printf("Each person pays: %.2f%n", perPerson);    }}​