Answer to Question #279756 in Java | JSP | JSF for Manny

Question #279756

It has been decided that transfers less than $100 should not attract any charges. However, transfers from $100 should attract a 17.5% charge on the amount being transferred. However, all road tolls has been abolished. The table below show the amount paid by drivers of the various vehicles.


VEHICLE TYPE....NAME....AMOUNT PAID ($)


1. saloon cars......Saloon_cars.....0.50

2. mummy wagons.....Trotro.....1.00

3. heavy buses.....Buses2Axles......1.50


You are to write a Java program that takes three mobile money transfers of various amounts and compute the various charges and the sum of these charges should be the total change. Your program should take toll booth levy for the three vehicles, sum them and multiply the total levy by 5.


Find the difference between the total mobile money transfer and the total toll booth levy.


1
Expert's answer
2021-12-15T11:37:58-0500
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        double totalTransfers = 0;
        double totalToll = 0;
        Scanner in = new Scanner(System.in);
        for (int i = 0; i < 3; i++) {
            System.out.print((i + 1) + " mobile transfer: ");
            double mobileTransfer = Double.parseDouble(in.nextLine());
            if (mobileTransfer >= 100) {
                totalTransfers += mobileTransfer * 1.175;
            } else {
                totalTransfers += mobileTransfer;
            }
        }

        for (int i = 0; i < 3; i++) {
            System.out.print((i + 1) + " toll booth levy: ");
            double toll = Double.parseDouble(in.nextLine());
            totalToll += toll;
        }
        totalToll *= 5;
        System.out.println(totalTransfers - totalToll);
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog