1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kramer
4 years ago
5

Need help with this C++ question

Computers and Technology
1 answer:
sertanlavr [38]4 years ago
4 0

Answer:

Here is the improvement of the program:

#include<iostream>  //to use input output functions

using namespace std;// to identify objects like cin cout

int main()  {   //start of main function

  string pet;         // "cat" or "dog"  

  char spayed;       // 'y' or 'n'      

  // Get pet type and spaying information  

cout << "Enter the pet type (cat or dog): ";   //prompts user to enter pet type

  cin  >> pet;   //reads input pet type

  if(pet=="cat"|| pet=="dog")     {   //use OR operator to check the type

  cout << "Has the pet been spayed or neutered (y/n)? ";   //prompts user to input if pet been spayed or neutered

  cin  >> spayed;}   //reads input spayed value

  else   // display the message below

  cout<<"only cats and dogs need pet tags";        

  // Determine the pet tag fee  

if (pet == "cat")   //if type of pet is cat

  {  if (spayed == 'y' || spayed == 'Y')  //lowercase or upper case y is accepted  

        cout << "Fee is $4.00 \n";   //if spayed is y or Y

     else   //if spayed is not y or Y

        cout << "Fee is $8.00 \n";   }  

  else if (pet == "dog")   //if type is dog

  {  if (spayed == 'y' || spayed=='Y')   //if spayed is y or Y

        cout << "Fee is $6.00 \n";  

     else   //if spayed is not y or Y

        cout << "Fee is $12.00 \n";    }        

  return 0;   }

 

Explanation:

Step 1:

Here is the copy of original source code:

#include <iostream>

using namespace std;

int main() {

string pet;

char spayed;

cout <<"Enter the pet type (cat or dog): ";

cin >> pet;

cout <<"Has the pet been spayed or neutered (y/n)?" ;

cin >>spayed;

if (pet=="cat") {

if (spayed=='y')

cout<< "Fee is $4.00 \n";

else

cout<< "Fee is $8.00 \n"; }

else if (pet== "dog") {

if (spayed=='y')

cout<<"Fee is $6.00 \n";

else

cout<<"Fee is $12.00 \n";}

else  

cout<<"Only cats and dogs need pet tags";

return 0; }

Step 2:

Compile the program and then run it 7 times

Run       Input Data         Fee Information                                      Correct

 1                cat y               Fee is $4.00                                           Yes  

 2               cat n               Fee is $8.00                                           Yes    

 3               cat Y               Fee is $8.00                                           No

 4               dog y              Fee is $6.00                                           Yes

 5               dog n              Fee is $12.00                                         Yes

 6               dog Y              Fee is $12.00                                         No

 7              hamster n        Only cats and dogs need pet tags       Yes                

Step 3:            

See the Answer section

OR logical operator is used so that either a lowercase 'y' or an uppercase 'Y is accepted:

if (spayed == 'y' || spayed == 'Y')

program only execute the spay/neuter prompt and input when the pet type is cat or dog:

if(pet=="cat"|| pet=="dog")  

 {     cout << "Has the pet been spayed or neutered (y/n)? ";    

cin  >> spayed; }    

else    

cout<<"only cats and dogs need pet tags";      

Step 4:

Run       Input Data         Fee Information                                      Correct

 1                cat y               Fee is $4.00                                           Yes  

 2               cat n               Fee is $8.00                                           Yes    

 3               cat Y               Fee is $4.00                                           Yes

 4               dog y              Fee is $6.00                                           Yes

 5               dog n              Fee is $12.00                                         Yes

 6               dog Y              Fee is $6.00                                           Yes

 7              hamster         Only cats and dogs need pet tags          Yes  

In the last input hamster the program does not ask for spayed information. It only asks to Enter the pet type. When the user enters hamster the program displays the message: Only cats and dogs need pet tags.

You might be interested in
Batter boards (if properly offset) will allow for the end user to continually re-string the layout to double check accuracy with
natulia [17]

Answer:

The given statement is "True".

Explanation:

  • Batter panels seem to be platform frames that are used to temporarily suspend foundations plan threads. These same batter board members look like barriers once built.
  • Its positioning is important for creating a foundation precisely as the plans state since some components of their development would have to be accurate. Placed correctly batter panels guarantee that the boundaries seem to be at the appropriate temperatures as well as positions.
4 0
3 years ago
Computer-aided design software can _________________ a. See details that could not be visible with drafting or modeling. B. Simu
kvasek [131]

Answer:

Your answer would be option D

Explanation:

Computer aided software can do everything that it states from A to D.

A, is true because it could display physics of items such as building models or cars.

B, This is very common such as WW11 movies and there backgrounds, such as a city that doesn't exist anymore or the world trade center before the incident.

C, With current tech you would make many different landscapes and areas that don't even exist like editing a grassy landscape during fall and putting snow over the land scape making it look like there is snow when there's not.

BRAINLEIST PLEASE! if you have any questions please ask.

6 0
3 years ago
You have a computer at home. The computer is connected to the Internet through a dial-up connection. Every time you connect to t
worty [1.4K]

Hiya!

When you connect to the internet (especially through a dial-up connection), your computer must make the request for network resources. This is usually done through a Modem, a device designed to establish and split the connection among your devices.

Fun fact; a dial up connection uses the same radio frequencies that you would use to talk on the phone; and they're in the audible spectrum. When you start up that connection, the reason all those funny noises happen is because it's "talking" to your ISP over those lines.

Hope this helps!

3 0
3 years ago
What kind of skills does an electronics engineering tech need as requirement in the workplace?
eduard

Answer:

Electrical and electronics engineering technicians should also possess the following specific qualities: Logical-thinking skills. Electrical and electronics engineering technicians must isolate and then identify problems for the engineering staff to work on. They need good reasoning skills to identify and fix problems.

Explanation:

3 0
3 years ago
NEED HELP
amid [387]

Answer:

i would do B

Explanation:

I YOUNGI

I MIDDLE I

I   AGED  I

I     MEH   I

I_______ I

\ kinda old/

  \ ____ /

   I OLD I

3 0
3 years ago
Other questions:
  • Which computer device works like the human central nervous system by connecting all the computer’s parts together and allowing t
    9·1 answer
  • Type the correct answer in the blank. Spell all words correctly.
    13·1 answer
  • Amina question and any other )
    14·1 answer
  • Which transmission media is faster? Fibre Optic or Radio-waves? I want full explanation!
    10·1 answer
  • Design the program that reads two files and compares their contents. The program calls a method that reads the file one line at
    10·1 answer
  • modified true or false analyze each statement then write technical the statement is true the statement is false underline the wo
    6·1 answer
  • I want to make a game with a friend. I use visual studio code. How do I work on the game with him? Like can he edit the same tim
    10·1 answer
  • Diane changes the size of an image with the format picture pane and keeps the original ratio of height to width of the object. W
    8·1 answer
  • What construction work is the tender for​
    10·2 answers
  • Does anyone have any tips on how to begin a 10 page Capstone project paper? I've got to write a write a research paper on the ty
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!