Question: Lab 4 Calculator Program CSCI 111 Programming and Algorithms I Due Tuesday February 2, 11:59pm on turnin 10 Points OBJECTIVE: This lab covers two important

Lab 4

Calculator Program

CSCI 111 Programming and Algorithms I

Due Tuesday February 2, 11:59pm on turnin

10 Points

OBJECTIVE: This lab covers two important C++ constructs, the cin for user input and the if statement.

Here is some sample code you should be familiar with. Please note that the symbols != means not equal.

#include

using namespace std;

int main()

{

int mynumber;

cout << "Enter the number 3" << endl;

cin >> mynumber;

if ( mynumber == 3 )

[

cout << "Correct" << endl;

}

if ( mynumber != 3 )

{

cout << "Not Correct" << endl;

}

return 0;

)

Task list:

1. Edit / compile / execute the above code to ensure you have a good understanding.

2. Create a source code file named lab4.cpp which performs like a calculator (your code should be able to match EXACTLY the bold output listed below). Notice that you first prompt the user for 2 numbers then you prompt the user to enter 1, 2, 3, or 4.

3. Compile and execute the code. Recall the respective commands: Compile the source code: g++ -std=c++11 -o lab4 lab4.cpp Execute the object code: ./lab4

4. Confirm that your code is correct for all 4 arithmetic operations.

5. If you are working on this lab remotely, then transfer the lab4.cpp code from jaguar to your laptop.

6. Submit your lab4.cpp file on https://turnin.ecst.csuchico.edu/

7. Ensure that you get a successful message after submitting work via turnin.

GRADING

To achieve a maximum score, students will need to clearly prove that they completed the goal.

Points lost for incompleteness, sloppiness, lateness, or failure to follow instructions.

Refer to syllabus for late policy.

SAMPLE OUTPUT

/user/faculty/jraigoza/CSCI111/Labs/lab4 $ ./lab4

Enter your first number

4

Enter your second number

8

Enter 1=add 2=subtract 3=multiply 4=divide

1 Adding 4 and 8

The answer is > 12

/user/faculty/jraigoza/CSCI111/Labs/lab4 $ ./lab4

Enter your first number

8

Enter your second number

2

Enter 1=add 2=subtract 3=multiply 4=divide

2

Subtracting 8 and 2

The answer is > 6

/user/faculty/jraigoza/CSCI111/Labs/lab4 $ ./lab4

Enter your first number

6

Enter your second number

7

Enter 1=add 2=subtract 3=multiply 4=divide

3

Multiplying 6 and 7

The answer is > 42

/user/faculty/jraigoza/CSCI111/Labs/lab4 $ ./lab4

Enter your first number

24

Enter your second number

8

Enter 1=add 2=subtract 3=multiply 4=divide

4

Dividing 24 and 8

The answer is > 3

/user/faculty/jraigoza/CSCI111/Labs/lab4 $

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!