Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please explain and show all steps/coding! I have included what I have been trying to do, but I cannot seem to get the coding to

Please explain and show all steps/coding! I have included what I have been trying to do, but I cannot seem to get the coding to work! This is in C++. Thank you in advance!!!image text in transcribedimage text in transcribedimage text in transcribed

Here is the part that I started! Please follow all directions from above! :)

image text in transcribed

Assignment U.S. interstates are numbered 1-99. Odd-numbered highways run north/south, and even-numbered highways run east/west. Additionally, auxiliary highways are numbered 101-999 and service the primary highway indicated by the rightmost two digits. Interstate numbers divisible by 100 are invalid. For example, 1-640 services |-40, and I-275 services 1-75. Your assignment is to determine whether a given highway number is a primary or auxiliary highway. If it is an auxiliary highway, indicate what primary highway it serves. Additionally, indicate if the primary highway runs north/south or east/west. You are required to implement error checking and display an error message using cerr and return 1 if cin fails to read an integer from the user input or the integer is invalid. See slides 9-10 of 03 Switch Statements, Ternary Operator, and Error Checking.pdf. Input Read a single integer value from the user after prompting for an interstate highway number. Output Your output messages should match the examples shown below exactly. User input is in red. Each preformatted box is a separate program execution. Enter an interstate number: 40 I-40 is a primary interstate, going east/west. Enter an interstate number: 275 I-275 is an auxiliary highway, serving I-75, going north/south. Enter an interstate number: 0 0 is not a valid interstate number. Enter an interstate number: 500 500 is not a valid interstate number. Enter an interstate number: -25 -25 is not a valid interstate number. Enter an interstate number: 1-50 Invalid integer value specified. Enter an interstate number: 55N I-55 is a primary interstate, going north/south. Restrictions 1. You must NOT duplicate any code. If you notice that you're writing the same statement, you need to rethink the flow of your code. 2. You must use if statements to error check the user's input, and you must use mutual exclusion where applicable (i.e., else if and/or else). 3. You must check that the user has input a valid integer. If not, output an error message using cerr instead of cout (see Output 5 above) and return 1 to exit your program with an error specified. 4. You may not call any functions (if you know how). 5. Comments and good formatting are required. Compiling You will compile your C++ program by typing the following command: g++ -std=c++11 -Wall -o lab3 lab3.cpp #include #include using namespace std; int main() int n; cout > n; cout

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_2

Step: 3

blur-text-image_3

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

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions

Question

1. Who should participate and how will participants be recruited?

Answered: 1 week ago