Day 2 :Operators.
Solution In Java 8:
import java.io.*;import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Arithmetic {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
double mealCost = scan.nextDouble();
int tipPercent = scan.nextInt();
int taxPercent = scan.nextInt();
scan.close();
double tip = mealCost*((double)tipPercent/100);
double tax = mealCost*((double)taxPercent/100);
Double cost = (Double) mealCost + tip + tax ;
int totalCost = (int) Math.round(cost);
System.out.println("The total meal cost is "+totalCost+ " dollars.");
}
}
0 comments:
Post a Comment