Question

In: Computer Science

Automobile Insurance Program: Writes a program that prints the insurance fee to pay for aVehicle...

Automobile Insurance Program:

Writes a program that prints the insurance fee to pay for a Vehicle according to the following rules:

  • A Honda that is All Wheel Drive costs $450.

  • A Honda that is two wheels drive costs $350.

  • A Toyota that is All Wheel Drive costs $300.

  • A Toyota that is Two Wheel Drive costs $250.

  • A Nissan that is All Wheel Drive costs $200.

  • A Nissan that is Two Wheel Drive costs $280.

Solutions

Expert Solution



import java.util.Scanner;

public class AutomobileInsurance {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("Enter make of the car(Honda, Toyota or Nissan): ");
        String make = in.next();
        System.out.print("1. All Wheel drive, 2. Two wheels. Enter your choice: ");
        int tyreType = in.nextInt();
        if (make.equalsIgnoreCase("Honda")) {
            if (tyreType == 1) {
                System.out.println("Insurance cost is $450");
            } else {
                System.out.println("Insurance cost is $350");
            }
        } else if (make.equalsIgnoreCase("Toyota")) {
            if (tyreType == 1) {
                System.out.println("Insurance cost is $300");
            } else {
                System.out.println("Insurance cost is $250");
            }
        } else if (make.equalsIgnoreCase("Nissan")) {
            if (tyreType == 1) {
                System.out.println("Insurance cost is $200");
            } else {
                System.out.println("Insurance cost is $280");
            }
        } else {
            System.out.println("Invalid manufacturer type. Try again!");
        }
        in.close();
    }
}

Related Solutions

Automobile Insurance Program: Writes a program that prints the insurance fee to pay for a Vehicle...
Automobile Insurance Program: Writes a program that prints the insurance fee to pay for a Vehicle according to the following rules: A Honda that is All Wheel Drive costs $450. A Honda that is two wheels drive costs $350. A Toyota that is All Wheel Drive costs $300. A Toyota that is Two Wheel Drive costs $250. A Nissan that is All Wheel Drive costs $200. A Nissan that is Two Wheel Drive costs $280.
Writes a program that prints the insurance fee to pay for a Vehicle according to the following rules:
C++ ProgrammAutomobile Insurance Program:Writes a program that prints the insurance fee to pay for a Vehicle according to the following rules:A Honda that is All Wheel Drive costs $450.A Honda that is two wheels drive costs $350.A Toyota that is All Wheel Drive costs $300.A Toyota that is Two Wheel Drive costs $250.A Nissan that is All Wheel Drive costs $200.A Nissan that is Two Wheel Drive costs $280Any other type of vehicle generates an error message. The program should...
Write a program that prints the insurance fee to pay for a pet according to the...
Write a program that prints the insurance fee to pay for a pet according to the following rules:(NOTE:You must use a switch statement to determine pet fee.)A dog that has been neutered costs $50.A dog that has not been neutered costs $80.A cat that has been spayedcosts $40.A cat that has not been spayedcosts $60.A bird or reptile costs nothing.Any other animal generates an error message.The program should prompt the user for the appropriate information: a character code for the...
Write a C++ program that prints the insurance fee to pay for apet according to...
Write a C++ program that prints the insurance fee to pay for a pet according to the following rules:(NOTE:You must use a switch statement to determine pet fee.)A dog that has been neutered costs $50.A dog that has not been neutered costs $80.A cat that has been spayedcosts $40.A cat that has not been spayedcosts $60.A bird or reptile costs nothing.Any other animal generates an error message.The program should prompt the user for the appropriate information: a character code for...
Write a program to determine the cost of an automobile insurance premium, based on the driver's...
Write a program to determine the cost of an automobile insurance premium, based on the driver's age and the number of accidents that the driver has had. The basic insurance charge is $500.There is a surcharge of $100. if the driver is under 25 and an additional surcharge for accidents: No. of accidents ► Accident Surcharge 1 ► 25 2 ► 25 3 ► 75 4 ► 75 5 ► 100 6 or + ► No assurance
Automobile insurance companies require drivers they insure have a valid drivers’ license and will not pay...
Automobile insurance companies require drivers they insure have a valid drivers’ license and will not pay 100% of damage claims. Explain why.
Write a program that asks the user for an integer. The program checks and prints to...
Write a program that asks the user for an integer. The program checks and prints to the screen whether the number is prime or not. For example, if user enters 17, the program should print “17 is prime”; if the user enters 20, the program should print “20 is not prime”. please do it with a “ while Loop”, Thanks..
C++ Goals: Write a program that works with binary files. Write a program that writes and...
C++ Goals: Write a program that works with binary files. Write a program that writes and reads arrays to and from binary files. Gain further experience with functions. Array/File Functions Write a function named arrayToFile. The function should accept three arguments: the name of file, a pointer to an int array, and the size of the array. The function should open the specified file in binary made, write the contents into the array, and then close the file. write another...
A program written in C that asks for the distance to be entered and then prints...
A program written in C that asks for the distance to be entered and then prints the fare A transportation company has the following rates For the first 100 miles                                                       20 cents a mile For the next 100 miles                                                       a) + 10 cents per mile over 100 miles For the next 100 miles                                                       b) + 8 cents per mile over 200 miles more than 300 miles                                                          c) + 5 cents per mile over 300 miles Write a program that asks...
C program, please Write a program that reads a sequence of 10 integer inputs and prints...
C program, please Write a program that reads a sequence of 10 integer inputs and prints the smallest and largest of the inputs and the number of even and odd inputs. for a beginner please, you could use a while loop,if-else,
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT