How would you write this program?

Im writing a program in class. You're suppose to write a program that prints out pet insurance fee

Write a program that prints the insurance fee to pay for a pet according to the following rules:
(Note: 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 neutered costs $40.
A cat that has not been neutered costs $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 status(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”

so far here is my code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <iostream>

using namespace std;

 

int main()

{

  char neutered, opselect, animal;

  const int dogcost = 80, catcost = 60, birdOrReptilecost = 0;

 

  cout << "What kind of animal do you have?\n";

  cout << "d for dog, c for cat, b for bird or reptile and o for others.\n\n";
  cin >> animal;
    
  cout << "Answer the following questions\n";
  cout << "With Y for yes or N for no.\n\n";
  cout << "Is your pet neutered? ";
  cin >> neutered;
   

  cout << "Enter a select code: ";

  cout << "\n1)A dog that has been neutered: ";

  cout << "\n2)A dog that has not been neutered: ";

  cout << "\n3)A cat that has been neutered costs: ";

  cout << "\n4)A cat that has not been neutered costs: ";

  cout << "\n5)A bird or reptile: ";
   
  cin >> opselect;

  switch (opselect)

  {

   case 1:

     cout << "The price for dog that has been neutered is " << dogcost - 30;

     break;

   case 2:

     cout << "The price for dog that has not been neutered is " << dogcost << endl;

    break;

   case 3:

     cout << "The price for cat that has been neutered is " << catcost - 20 << endl;

    break;

   case 4:

     cout << "The price for cat that has not been neutered is " << catcost << endl;

    break;

   case 5:

     cout << "The price for bird or reptile is " << birdOrReptilecost << endl;
    break;
{ 
	return 0;

}

should i just use if/elif/else condition?
What you want to do is ask the user for the type of animal they want.

ask if they want the animal neutered.

then switch the type of animal,
then use if and else statements to determine the price.
you ask what type of animal it is
then ask if the animal is neutered
then it tells you what the cost of the animals insurance is
Topic archived. No new replies allowed.