Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Section B (36%) - Short Questions Answer ALL questions in this section in the answer book provided. Each question carries 12 marks. Question B1 Write

Section B (36%) - Short Questions Answer ALL questions in this section in the answer book provided. Each question carries 12 marks. Question B1 Write your code for the main() function to produce the required sample outputs. The program asks the user for an 8-digit phone number. If the entered number is not an 8-digit number, it prints an error message and asks the user to input again until it is correct. It then prints whether it is a "fixed-line" number (a number that starts with 3 or 5), a "mobile" number (a number that starts with 6 or 9), or an "invalid" number (other cases). #include using namespace std; int ( operatorname{main}() ) i int phone_num; cout ( ll ) "Enter 8-digit phone number: "; cin ( gg ) phone_num; // Your codes for B1 should be inserted here return 0 ; } Sample output 1: Enter 8-digit phone number: 35124859 Fixed-line Sample output 2: Enter 8-digit phone number: 60125547 Mobile Sample output 3: Enter 8-digit phone number: 41242252 Invalid Sample output 4: Enter 8-digit phone number: 545678 Incorrect format. Re-enter: 545678912 Incorrect format. Re-enter: 54567891 Fixed-line (12 marks) Page 6 of 14
in c++ image text in transcribed
Section B (36%) - Short Questions Answer ALL questions in this section in the answer book provided. Fach question carries 12 marks. Question B1 Write your code for the main() function to produce the required sample outputs: The program asks the user for an 8 -digit phone number. If the enterod number is not an 8 -digit number, it prints an error message and asks the user to input again until it is correct. It then prints whether it is a "fixed-line" number (a number that starts with 3 or 5 ), a "mobile" number (a number that starts with 6 or 9 ), or an "imvalid" number (other cases). \#friclude Ciostream? using famespace atd? int main () Int phone tum: cout "Enter 8-digit phone number: " ? cin phone num? // Your codes for B1 should be inserted here return 0; 1 Sample output I: Enter 8-digit phone number: 35124859 Fixed-1ine Sample output 2: Fnter 8-digit phone number: 60125547 Mobile Sample output 3 : Enter 8-digit phone number: 41242252 Imvalid Sample output 4: Sampicoutput 4: Enter 8-difit phone number: 545678 Incorrect Cormat. Re-enter: 545678912 Incorrect format. Re-enter: $4567891 Fixed-ine (12 marks) Page 6 of 14

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

More Books

Students also viewed these Databases questions