Question

Programming, Use IF-THEN structure to write a C++ program that output Male if the gender input...

Programming, Use IF-THEN structure to write a C++ program that output Male if the gender input is ‘M’ or 'm', Female if the gender is ‘F’ or 'f', and invalid gender otherwise. 1) Declare variable, 2) draw your flow chart on the back, and 3) do the coding in C++.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1) The variable declaration:

char gender;

2) The flow chart is given below:

inder No Yes MALE ors Nos FEMALE INVALID GENDER

3)

CODE

======================

#include <iostream>

using namespace std;

int main() {
char gender;
cout << "Enter the gender (M/F) : ";
cin >> gender;
  
if(gender == 'm' || gender == 'M') {
cout << "You have entered MALE" << endl;
} else if(gender == 'f' || gender == 'F') {
cout << "You have entered FEMALE" << endl;
} else {
cout << "You have entered INVALID GENDER!!";
}
  
return 0;
}

Enter the gender (M/F) : You have entered FEMALE

Add a comment
Know the answer?
Add Answer to:
Programming, Use IF-THEN structure to write a C++ program that output Male if the gender input...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program (code) that performs the following: Height and Weight for Male and Female: Robinson...

    Write a program (code) that performs the following: Height and Weight for Male and Female: Robinson formula to calculate the body relative to the height in inches is as follow: Ideal weight in kilogram = 52 + 1.9 * (height - 60) for male Ideal weight in kilogram = 49 + 1.7 * (height - 60) for female Write a program that prompts the user to enter the gender ('M' or 'm' for male and 'F' or feet and inches,...

  • In C programming Write a program that displays the appropriate prompt to input 5 scores. Once...

    In C programming Write a program that displays the appropriate prompt to input 5 scores. Once the user inputs the five integer values, your program calculates and prints the average. You do not need to declare five different variables, think of how you can get away with a single variable. The second part of this program will print A if the average of these 5 numbers is greater than or equal to 90 but less than 100, B if greater...

  • C Programming QUESTION 9 Write a program that prompts for and reads four integer input values,...

    C Programming QUESTION 9 Write a program that prompts for and reads four integer input values, then a single character command. Submit your program as a .c file named midterm_prog2.c. Note that, similarly to your programming assignments, some percentage of your grade will depend on proper programming style. Your program will calculate and print a new value based on the command that's entered, as follows: 'A' or 'a': Calculate the average of the four input values 'S' or 's': Calculate...

  • Programming Language is Java Lab 1: Programming Exercises Input/Process/Output 1) Run the Numbers. Write a program...

    Programming Language is Java Lab 1: Programming Exercises Input/Process/Output 1) Run the Numbers. Write a program with two input values. The program should display the sum, difference, quotient, product, and average of the two numbers. 2) Jake’s Problem. Jake has a car with an 8-gallon fuel tank. Jake fills his tank with gas and drives 60 miles to a friend’s house. When he gets to his friend’s house, he has 6 gallons left in his fuel tank. Write a program...

  • In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one...

    In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one character string. Using a single dimension array, populate the array with the character string, call a function using pointers to reverse order the character string, pass back to the main the output and total_count_of_characters. (maybe use a global variable for the total count). Print display the reversed char string and total_count.

  • In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one...

    In C Programming Language, write a program Character Pointers and Functions. Keyboard input to enter one character string. Using a single dimension array, populate the array with the character string, call a function using pointers to reverse order the character string, pass back to the main the output and total_count_of_characters. (maybe use a global variable for the total count). Print display the reversed char string and total_count.

  • 2. Use function to write a program that prints all prime numbers in a range of...

    2. Use function to write a program that prints all prime numbers in a range of a user input numbers. a. Draw a flow chart for the function IsaPrimenumber [5 marks] b. Draw a flow chart for the whole scenario [10 marks] c. Convert the flow charts to a c program. [15 marks] In C programming language

  • C Programming Quesition (Structs in C): Write a C program that prompts the user for a...

    C Programming Quesition (Structs in C): Write a C program that prompts the user for a date (mm/dd/yyyy). The program should then take that date and use the formula on page 190 (see problem 2 in the textbook) to convert the date entered into a very large number representing a particular date. Here is the formula from Problem 2 in the textbook: A formula can be used to calculate the number of days between two dates. This is affected by...

  • write a program for topological ordering of a graph in c/c++ programming. The input contains a...

    write a program for topological ordering of a graph in c/c++ programming. The input contains a list of adjacent list of a directed acyclic graph. The output is a topological ordering of verticies.

  • In this program, you will be using C++ programming constructs, such as functions. main.cpp Write a...

    In this program, you will be using C++ programming constructs, such as functions. main.cpp Write a program that asks the user to enter an integer value. Your program will then display that integer back to the user. Your program should include a function called getInteger that requests an integer value from the user and returns that value back to the caller. Your main () function will call the function getInteger and will then display the value returned by that function....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT