Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Assume <iostream> has been included and the following variable has been declared:
char ch;
Create code that would be a part of main() that will do the following:
- Prompt the user to enter one of the following characters: c, n, a, or f
- Use a nested if-else statement to display one of the following strings:
- “CBS is on Channel 2 in Los Angeles” if the character is ‘c’ or ‘C’
- “NBC is on Channel 4 in Los Angeles” if the character is ‘n’ or ‘N’
- “ABC is on Channel 7 in Los Angeles” if the character is ‘a’ or ‘A’
- “FOX is on Channel 11 in Los Angeles” if the character is ‘f’ or ‘F’
- “Invalid character entered” if any other character is entered
Here are the rules:
- Submit only the code you are asked to write. You do not need to submit a main program. Please include the function header.
- Your code must follow all C++ syntax rules and compile.
- You must use a nested if-else statement.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Which of the following statements places input into the variable "value"?a) value >> cin;b) cin >> value;c) value << cin;d) cin << value;arrow_forwarda)Create a string variable and assign to it your favorite color. b) Write Matlab code that prompts the user to guess your favorite color. After the user has had 3 attempts, the program displays the message "Incorrect. You run out of chances!" and stops.arrow_forwardWhy does this code give me a C6031 error? #include <stdio.h> int main() { // Declare a variable to store the age int age; // Prompt the user to enter their age printf("Enter your age: "); // Read the entered age from the user scanf("%d" , &age); // Print the entered age printf("You entered: %d years old\n", age); return 0;}arrow_forward
- #include <iostream>#include <string>#include <fstream>#include <iomanip>#include <sstream> #include "card.h"#include "deck.h"#include "hand.h" using namespace N; using namespace std; /**main() controls the operation of the program*/ int main(){string repeat = "Y";Deck myDeck;Hand myHand;string exchangeCards; while (repeat == "Y" || repeat == "y"){cout << endl; myHand.newHand(myDeck);myHand.print();cout << endl; cout << "Would you like to exchange any cards? [Y / N]: ";getline(cin, exchangeCards); while (exchangeCards != "Y" && exchangeCards != "y" && exchangeCards != "X" && exchangeCards != "n"){cout << "Please enter Y or N only: ";getline(cin, exchangeCards); } if (exchangeCards = "Y" || exchangeCards = "y"){myHand.exchangeCards(myDeck);}cout << endl; myHand.print(); cout << endl; myDeck.reset(); // Resets the deck for a new game cout << "Play again? [Y / N]: ";getline(cin, repeat);while…arrow_forward(1) Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. Ex: Enter a sample text: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue! You entered: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue! (2) Implement a PrintMenu() function, which has a string as a parameter, outputs a menu of user options for analyzing/editing the string, and returns the user's entered menu option. Each option is represented by a single character. If an invalid character is entered, continue to prompt for a valid choice. Hint: Implement Quit before implementing other options. Call PrintMenu() in the main() function. Continue to call…arrow_forwardWhat does the following code segment output? Assume that a variable is declared. int x= 5; for (; ; x++) { if (x < 6) 11 cout<< x << else break; } A. 5 6 В. 5 C. 6 D. Errorarrow_forward
- 6. infave = Given the following code segment, what is the output? int x = 1, y = 1, z = 1; %3D Y - y + z; x = x + y: cout <« "result = " << (x < y ? y: x) <« endl;arrow_forwardAssume <iostream> has been included and the following variable has been declared: char ch; Create code that would be a part of main() that will do the following: Prompt the user to enter one of the following characters: c, n, a, or f Use a nested if-else statement to display one of the following strings: “CBS is on Channel 2 in Los Angeles” if the character is ‘c’ or ‘C’ “NBC is on Channel 4 in Los Angeles” if the character is ‘n’ or ‘N’ “ABC is on Channel 7 in Los Angeles” if the character is ‘a’ or ‘A’ “FOX is on Channel 11 in Los Angeles” if the character is ‘f’ or ‘F’ “Invalid character entered” if any other character is enteredarrow_forwardyou have to use "Kaniz Fatema" as name. And middle initial will be "S"arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education