Question

In: Computer Science

Using C++, Right down a code that calculates insuranceprice:* requires driver to enter their...

Using C++, Right down a code that calculates insurance price:

* requires driver to enter their age and the amounts of accidents they have had

based on that:

*base price is $500

*additional fees of $100 if driver is younger than 25

*additional fees based on accidents:

number of accidentsfees of accidents
150
2125
3225
4375
5575
6 or moreno insurance

*Use switch

*if had 6 or more accidents won't be able to get insurance


Solutions

Expert Solution

Using C++,calculates insurance price:

Program:

#include
using namespace std;
int main(){
   int base = 500;
   int age;
   int number_of_accidents;
   int choice;
   cout << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ";
   cout << " * Calculating insurance price: * ";
   cout << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ";
   do{
       cout << " 1.Calculate the insurance ";
       cout << "2.Exit the program ";
       cout << "Enter you choice :";
       cin >> choice;
       switch(choice){
           case 1:
               cout << " Enter the age: ";
               cin >> age;
               if(age < 25){
                   base += 100;
               }
               cout << "Number of accidents: ";
               cin >> number_of_accidents;
               switch(number_of_accidents){
                   case 1:
                       base += 50;
                       cout << "Insurance price is " << base << " ";
                       break;
                   case 2:
                       base += 125;
                       cout << "Insurance price is " << base << " ";
                       break;
                   case 3:
                       base += 225;
                       cout << "Insurance price is " << base << " ";
                       break;
                   case 4:
                       base += 375;
                       cout << "Insurance price is " << base << " ";
                       break;
                   case 5:
                       base += 575;
                       cout << "Insurance price is " << base << " ";
                       break;
                   case 6:
                       cout << "no insurance for 6 or more accidents ";
                       break;
                   default :
                       cout << "no insurance for 6 or more accidents ";
                       break;
                      
               }
       }
   }while(choice != 0);
   return 0 ;
}


Related Solutions

using C++. edit this code down below so that it will implement stack with linked list...
using C++. edit this code down below so that it will implement stack with linked list contains a default constructor, a copy constructor, and a destructor. #include <iostream> #include <vector> #include <string> #include <stack> #include <limits> using namespace std; class Stack { public: bool isEmpty(); int top(); int pop(); void push(int); void printList(); private: vector<int> elements; }; bool Stack::isEmpty() { return elements.empty(); } int Stack::top() { if(isEmpty()) { throw runtime_error("error: stack is empty"); } return elements.back(); } int Stack::pop() {...
C++ Write the C++ code for a void function that prompts the user to enter a...
C++ Write the C++ code for a void function that prompts the user to enter a name, and then stores the user's response in the string variable whose address is passed to the function. Name the function getName.
in C please! Write a code that asks user for input N and calculates the sum...
in C please! Write a code that asks user for input N and calculates the sum of the first N odd integers. There should be a "pure" method that calculates the sum separately that Main method should call when printing the output.
Code should be written in C++ using Visual Studios Community This requires several classes to interact...
Code should be written in C++ using Visual Studios Community This requires several classes to interact with each other. Two class aggregations are formed. The program will simulate a police officer giving out tickets for parked cars whose meters have expired. You must include both a header file and an implementation file for each class. Car class (include Car.h and Car.cpp) Contains the information about a car. Contains data members for the following String make String model String color String...
Create a python code that calculates fixed point iteration method using a for loop.
Create a python code that calculates fixed point iteration method using a for loop.
Complete the R code using Rstudio so that it calculates and returns the estimates of β,...
Complete the R code using Rstudio so that it calculates and returns the estimates of β, the intercept and regression weight of the logistic regression of approximate GPA on Rouder-Srinivasan preference. ## Data Preference <- c( 0, 0, 0, 0, 0, 1, 1, 1, 1) # 0: Rouder; 1: Srinivasan GPA <- c(2.0, 2.5, 3.0, 3.5, 4.0, 2.5, 3.0, 3.5, 4.0) Count <- c( 4, 5, 21, 22, 8, 2, 1, 4, 7) # Define the deviance function deviance <-...
WPF application that calculates insurance rates using complex conditional statements. Include the ability to enter the...
WPF application that calculates insurance rates using complex conditional statements. Include the ability to enter the gender and age and click a button to calculate the insurance rate. C#
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates...
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates and displays the total travel expenses of a business person on a trip. Here is the information that the user must provide: • Number of days on the trip • Amount of airfare, if any • Amount of car rental fees, if any • Number of miles driven, if a private vehicle was used • Amount of parking fees, if any • Amount of...
Write a C++ code to ask the user to enter 4 values (whole numbers). Your code...
Write a C++ code to ask the user to enter 4 values (whole numbers). Your code should print the numbers in descending order.
JAVA I need to write a code that calculates mean and standard deviation using arrays and...
JAVA I need to write a code that calculates mean and standard deviation using arrays and OOP. This is what I have so far. I'm close but my deviation calculator method is throwing errors. Thanks so much :) import java.util.Scanner; import java.util.Arrays; public class STDMeanArray { private double[] tenUserNums = new double[10];//Initialize an array with ten index' private double mean; private double deviation; Scanner input = new Scanner(System.in);//create new scanner object /*//constructor public STDMeanArray(double tenUserNum [], double mean, double deviation){...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT