Question: Login to your Linux account. 3. At the Linux command line type mkdir lab 1 . This will create a new directory named lab 1

Login to your Linux account.

3.

At the Linux command line

type

mkdir lab

1

. This will

create a new directory

named

lab

1

. Wor

k out of this directory. In order to do that, type

cd lab

1

. This changes the

current working directory to the directory

lab

1

.

4.

If yo

u have created the directory

lab

1

, then

just

type

cd lab

1

.

5.

Copy the file

basics

.exe

in the directory

/class/cse1222/

8

782

/

lab

1

by typing

cp /class/cse1222/

8

782

/lab

1

/

basics

.exe

.

Be sure to

include

8

782

(this is your course section indicator)

and the

period

..

Programming Assignment

1.

Create a new file

called

basics

.cpp

using the Emacs editor (as you did in lab last week)

which will contain

a program t

hat asks the user to enter values of different types and

then

displays computa

tion performed on these values.

CSE1222

Autumn

201

7

CSE1222

Lab

1

2

Enter the following initial code in the file

basics

.cpp

:

// File: basics.cpp

// Created by: Your Name

// Created

on: Creation Date

/* This program illustrates

the use of keyboard input, data

types,

variables, assignment statements, and output

*/

#include

using namespace std;

int main()

{

double

x

;

int

y

,

z

;

char character;

// insert your solution here

return(0);

}

2.

Replace Your name with your name

.

3.

Replace

Creation Date with todays date

.

4.

The progra

m above declares four variables:

a character value, a double value, and two integer

values. You will write a program that will prompt the user

(use

cout

) and read (use

cin

)

these four values

from the keyboard

and then displays computation on these values. Your

program will first ask the

user to enter a character value, then a double value, and finally the

two integer values.

It will then compute and display the results of various math formulas.

a.

From

the Linux command line run

the

solution

I provide

in the

executable

file

basics.exe

.

b.

Your

solution must match the behavior

and output

of this solution

exactly

. This

includes the text displayed

, empty lines,

and results of the computation

displayed to

the screen

.

c.

Run the solution a few times with different input values to get a good idea of what

computations are being done.

5.

Write your solution in th

e above initial code below

// insert your solution here

so that your

program behaves exactly as the solution provided in the executable

basics.exe

.

Your

program must produce exactly t

he same output

as the solution

basics.exe

on the same

inputs values.

a.

Do n

ot use any more variables in your solution than the four provided above. You

must use all four

of these

variables in your solution.

CSE1222

Autumn

201

7

CSE1222

Lab

1

3

b.

***

Do not write your

code all at once

!

***

Instead write your cod

e

incrementally

.

T

his means write only a couple or

few lines of code in your solution and then compile

and run the code immediately. Test this code with different

input

values

. If these few

lines of code work, then write a few more lines and do the s

ame ov

er again. By

writing your

solution

step

-

by

-

step

and

repeatedly compiling, running, and testing

as

you develop your program

you will arrive at a correct solution

quicker

. It is good to

develop good programming habits early (ask your instructor).

Fo

r

example, first write only enough code to simply prompt the user for a character

Enter a character:

and then read a character f

rom the user. The entered

value

should be stored in the variable

character

(see code template above). If this

code compiles and

runs successfully then continue with your solution by writing only

enough code to prompt and read from the user

for

the double value. If your code

compiles and runs successfully for both of these tasks then continue to write your

solution

incrementally

in

this manner.

Compile and run your program

. Thoroughly

test

your program by checking its output against

basics.exe

. Run your solution

on

many

input values

to e

nsure that all mathematical

formulas are correct

.

Submit Your Work

Important

: Any program which

does not compile and run will receive no credit!

If you are not sure what this means please ask your instructor.

Submit your file

basics

.cpp

using the

L

ab

1

drop box on Carmen

using the Assignments

tab

.

DO NOT

submit the file

a.out

.

DO NOT

submit uncompleted work fro

. This will

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!