Computers and Technology

1 #include 2 using namespace std;
3
4 int main() {
5 int userNum;
6 int userNumSquared;
7
8 cin >> userNum;
9
10 userNumSquared = userNum + userNum; // Bug here; fix it
11
12 cout << userNumSquared; // Output formatting issue |
13
14 return 0;
15 }
16
While the zyLab platform can be used without training, a bit of training may help some students avoid common issues.
The assignment is to get an integer from input, and output that integer squared, ending with newline. (Note: This assignment is configured to have students programming directly in the zyBook. Instructors may instead require students to upload a file). Below is a program that's been nearly completed for you.
Click "Run program". The output is wrong. Sometimes a program lacking input will produce wrong output (as in this case), or no output. Remember to always pre-enter needed input.
Type 2 in the input box, then click "Run program", and note the output is 4.
Type 3 in the input box instead, run, and note the output is 6.
When students are done developing their program, they can submit the program for automated grading.
Click the "Submit mode" tab
Click "Submit for grading".
The first test case failed (as did all test cases, but focus on the first test case first). The highlighted arrow symbol means an ending newline was expected but is missing from your program's output.
Matching output exactly, even whitespace, is often required. Change the program to output an ending newline.
Click on "Develop mode", and change the output statement to output a newline: cout << userNumSquared << endl;. Type 2 in the input box and run.
Click on "Submit mode", click "Submit for grading", and observe that now the first test case passes and 1 point was earned.
The last two test cases failed, due to a bug, yielding only 1 of 3 possible points. Fix that bug.
Click on "Develop mode", change the program to use * rather than +, and try running with input 2 (output is 4) and 3 (output is now 9, not 6 as before).
Click on "Submit mode" again, and click "Submit for grading". Observe that all test cases are passed, and you've earned 3 of 3 points.

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:00, Yamari000
What are two of the most common reasons that peolpe who need mental health care do not access it?
Answers: 1
image
Computers and Technology, 23.06.2019 02:00, eila3601
As with any small island country, cuba has fewer natural resources than countries such as brazil. this affects their economy in that cuba a) exports only manufactured products. b) exports more products than it imports.. c) must import more products than it exports. d) has imposed trade barriers against the united states.
Answers: 3
image
Computers and Technology, 23.06.2019 12:20, jshhs
When guido van rossum created python, he wanted to make a language that was more than other programming languages. a. code-based b. human-readable c. complex d. functional
Answers: 1
image
Computers and Technology, 23.06.2019 22:20, Izzyfizzy
Read “suburban homes construction project” at the end of chapters 8 and 9 (in the textbook) and then develop a wbs (work breakdown structure) in microsoft excel or in microsoft word (using tables)
Answers: 1
Do you know the correct answer?
1 #include 2 using namespace std;
3
4 int main() {
5 int userNum;
6 int...

Questions in other subjects:

Konu
History, 08.07.2019 18:30