Menu

(Solved) : Please Explain Show Steps Coding Included Trying Cannot Seem Get Coding Work C Thank Adva Q43963999 . . .

Please explain and show all steps/coding! I have included what Ihave been trying to do, but I cannot seem to get the coding towork! This is in C++. Thank you in advance!!!Assignment U.S. interstates are numbered 1-99. Odd-numbered highways run north/south, and even-numbered highways run east/wesInput Read a single integer value from the user after prompting for an interstate highway number. Output Your output messagesRestrictions 1. You must NOT duplicate any code. If you notice that youre writing the same statement, you need to rethink th

Here is the part that I started! Please follow all directionsfrom above! 🙂

#include <iostream> #include <string> using namespace std; int main() int n; cout << Enter an interstate number: ; cin >> n

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 <iostream> #include <string> using namespace std; int main() int n; cout << “Enter an interstate number: “; cin >> n; cout << “I-” << n << ” is a”; if ( n % 2 == 0){ cout << ” primary interstate, going east/west.” << ‘n’; else { cout << “n auxiliary highway, serving I-” << n/100 << “, going north/ south” << ‘n’; if (n < 0) { cerr « n «< ” is not a valid interstate number.n”; else { cerr << “Invalid integer value specified. n”; return 1; Show transcribed image text 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

Expert Answer


Answer 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 co…

OR