subject

Need help with this C++ question Step 1: Add the follow ing lab6.cpp program. Here is a copy of the source code 2// This program determines the fee for a cat or dog pet tag. 3 // It uses nested if/else statements. 4 // PUT YOUR NAME HERE. 5 #include 6 #include 7 using namespace stod; 9 int main0) 10 string pet; "cat" or "dog 12 char spayed; l'y' or n 13 14 I/Get pet type and spaying information 15 cout <<"Enter the pet type (cat or dog): " 16 cin >> pet; 17 cout <<"Has the pet been spayed or neutered (y/n)?" 18 cin >>spayed; 19 20 / Determine the pet tag fee 21 if (pet--"cat") 22 if (spayed 'y) 23 cout<< "Fee is $4.00 n"; 24 else 25 cout<< "Fee is $8.00 n"; 26 27 else if (pet "dog") 28 if (spayed 'y) 29 cout<<"Fee is $6.00 In"; 30 else 31 out<<"Fee is $12.00 In"; 33 else 34 cout<<"Only cats and dogs need pet tags. In" 35 36 return 0;
Step 2: Compile the program and then run it 7 times. For each run use the input test data shown in the table below and write down the fee information that is displayed. Indicate whether or not the displayed information seems to be correct or not. Run Input data FeIformation Correct? cat y cat n cat Y 4 6 dog Y hamster n
Step 3: Improve the program in the following two ways. Use a logical OR on lines 22 and 28 so that either a lowercase 'y' or an uppercase 'Y is accepted. Currently when an animal other than a cat or dog is entered (such as a hamster), the program asks if it is spayed or neutered before displaying the message that only cats and dogs need pet tags. Find a way to make the program only execute the spay/neuter prompt and input when the pet type is cat or dog. Step 4: Recompile your revised previous table. Make sure it works correctly for all 7 cases. program and test it with the same 7 test cases given in the previous table. Make sure it works correctly in all 7 cases

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 02:00
What is the process in which the software development team compiles information to determine the final product.
Answers: 3
question
Computers and Technology, 22.06.2019 15:30
In a compound condition, both conditions on either side of the logical operator and must be true for the overall condition to be true. a: true b: false
Answers: 1
question
Computers and Technology, 22.06.2019 17:40
Write a modular program (no classes yet, just from what you learned last year), that allows two players to play a game of tic-tac-toe. use a two-dimensional char array with 3 rows and 3 columns as the game board. each element of the array should be initialized with an asterisk (*). the program should display the initial board configuration and then start a loop that does the following: allow player 1 to select a location on the board for an x by entering a row and column number. then redisplay the board with an x replacing the * in the chosen location. if there is no winner yet and the board is not yet full, allow player 2 to select a location on the board for an o by entering a row and column number. then redisplay the board with an o replacing the * in the chosen location. the loop should continue until a player has won or a tie has occurred, then display a message indicating who won, or reporting that a tie occurred. player 1 wins when there are three xs in a row, a column, or a diagonal on the game board. player 2 wins when there are three ox in a row, a column, or a diagonal on the game board. a tie occurs when all of the locations on the board are full, but there is no winner. input validation: only allow legal moves to be entered. the row must be 1, 2, or 3. the column must be 1, 2 3. the (row, column) position entered must currently be empty (i.e., still have an asterisk in it).
Answers: 1
question
Computers and Technology, 22.06.2019 22:30
Which of the following factors would your hypothetical supervisor look at when deciding whether to test a biological material sample for dna? the amount of other evidence you have implicating a suspect in a crime the annual budget for the crime lab both of the above none of the above; you would almost always order a test
Answers: 3
You know the right answer?
Need help with this C++ question Step 1: Add the follow ing lab6.cpp program. Here is a copy of the...
Questions
question
Mathematics, 24.10.2021 09:30
question
Mathematics, 24.10.2021 09:40
Questions on the website: 13722360