Question

In: Computer Science

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 the pet type, and a yes/no response for the neutered status. Use a code letter to determine the kind of animal (i.e. D or d represents a dog, C or c represents a cat, B or b represents a bird, R or r represents a reptile, and anything else represents some other kind of animal). Use a code letter to determine the neutered/spayedstatus(i.e. Y or y represents yes, N or n represents no). The user should be allowed to enter the input in either upper or lower case.It prints out the type of animal (full name of animal) and the insurance fee. Any error in input data should generate an error message “Invalid data –no fee calculated”.

Solutions

Expert Solution

C++ CODE:-

#include
using namespace std;
void Cal_fee_dog(char status)
{
   int p=50;
   int q=80;  
   cout<<"The type of animal is: DOG\n";
   if(status=='y' || status=='Y')
   {
       cout<<"The Insurance Fee to pay is:$"<< p ;
       cout<<"\n";
   }
   else if(status=='n'||status=='N')
   {
       cout<<"The Insurance Fee to pay is:$"<< q ;
       cout<<"\n";
   }
}

void Cal_fee_cat(char status)
{
   int p=40;
   int q=60;  
   cout<<"The type of animal is: CAT\n";
   if(status=='y' || status=='Y')
   {
       cout<<"The Insurance Fee to pay is:$"<< p ;
       cout<<"\n";
   }
   else if(status=='n'||status=='N')
   {
       cout<<"The Insurance Fee to pay is:$"<< q    ;
       cout<<"\n";  
   }
}

void Identify_bird()
{
   cout<<"The type of animal is: BIRD\n";
   cout<<"No Insurance Fee\n";
}

void Identify_reptile()
{
   cout<<"The type of animal is: REPTILE\n";
   cout<<"No Insurance Fee\n";
}

void Identify_animal()
{
   cout<<"Invalid data-no fee calculated";
   cout<<"\n";
}
int main()
{
   char ch,status;
   cout<<"Enter the character code for pet type:\n";
   cin>> ch;
   cout<<"Enter the response for neutered status:\n";
   cin>> status;
   /* cout<<"You entered:-"<    cout<<"\n";
   cout<<"You entered:-"<    cout<<"\n"; */
   switch(ch)
   {
   case 'd':
       Cal_fee_dog(status);
       break;
   case 'D':
       Cal_fee_dog(status);
       break;
   case 'c':
       Cal_fee_cat(status);
       break;
   case 'C':
       Cal_fee_cat(status);
       break;
   case 'b':
       Identify_bird();
       break;
   case 'B':
       Identify_bird();
       break;
   case 'r':
       Identify_reptile();
       break;
   case 'R':
       Identify_reptile();
       break;
   default:
       Identify_animal();
   }
   return 0;
}

SCREENSHOT of OUTPUT:-


Related Solutions

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...
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...
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.
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.
Programming in C++ Write a program that prints the values in an array and the addresses...
Programming in C++ Write a program that prints the values in an array and the addresses of the array’s elements using four different techniques, as follows: Array index notation using array name Pointer/offset notation using array name Array index notation using a pointer Pointer/offset notation using a pointer Learning Objectives In this assignment, you will: Use functions with array and pointer arguments Use indexing and offset notations to access arrays Requirements Your code must use these eight functions, using these...
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,
in C++ programing language Write a program that prompts the user for an integer, then prints...
in C++ programing language Write a program that prompts the user for an integer, then prints all of the numbers from one to that integer, separated by spaces. Use a loop to print the numbers. But for multiples of three, print "Fizz" instead of the number, and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz". Drop to a new line after printing each 20 numbers. If the user typed...
Write a C++ program to calculate the price of the annual insurance of a private vehicle according to the following table.
Write a C++ program to calculate the price of the annual insurance of a private vehicle according to the following table. Age of the person Model year of the car History of Accident Insurance price Less than 40 years Less than 2015 Yes 20 % more than price of last year No 15 % more than price of last year Later than 2015 Yes 12 % more than price of last year No 10 % more than price of last...
Write a c++ program that prints the count of all prime numbers between A and B...
Write a c++ program that prints the count of all prime numbers between A and B (inclusive), where A and B are defined as follows: A = Any 5 digit unique number B = A + 1000 Just a recap on prime numbers: A prime number is any number, greater or equal to 2, that is divisible ONLY by 1 and itself. Here are the first 10 prime numbers: 2, 5, 7, 11, 13, 17, 19, 23, and 29. Rules:...
Write a menu driven C++ program that prints the day number of the year , given...
Write a menu driven C++ program that prints the day number of the year , given the date in the form of month-day-year. For example , if the input is 1-1-2006 , then the day number is 1. If the input is 12-25- 2006 , the day number is 359. The program should check for a leap year. A year is leap if it is divisible by 4 but not divisible by 100. For example , 1992 , and 2008...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT