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...
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...
Need to write a c program Program prints a message telling the user to push a...
Need to write a c program Program prints a message telling the user to push a key to start the game. Once in game, output tells the player which key to push. The key to press should be determined randomly. Game runs continuously until the user reaches a loose condition. A wrong key is pressed
Write a C# program that prints a calendar for a given year. Call this program calendar....
Write a C# program that prints a calendar for a given year. Call this program calendar. The program prompts the user for two inputs:       1) The year for which you are generating the calendar.       2) The day of the week that January first is on, you will use the following notation to set the day of the week:            0 Sunday                     1 Monday                   2 Tuesday                   3 Wednesday       4 Thursday                 5 Friday                      6 Saturday Your program should...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT