Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.DecimalFormat;
- import java.util.Scanner;
- public class p02_TransportPrice {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double km = Double.parseDouble(scanner.nextLine());
- String daynight = scanner.nextLine().toLowerCase();
- DecimalFormat format = new DecimalFormat("#.##");
- if (km <20 && daynight.equals("day")){
- double price = 0.70 + 0.79*km;
- System.out.printf(format.format(price));
- } else if (km<20 && daynight.equals("night")){
- double price = 0.70 + 0.90*km;
- System.out.printf(format.format(price));
- }if (km>=20 && km<100){
- double price = km*0.09;
- System.out.printf(format.format(price));
- }else if (km>=100){
- double price = km*0.06;
- System.out.printf(format.format(price));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement