Your cart is currently empty!
Goals: Use of variables of type int, double, float, char, string Use of operators +, -, /, * Understand integer division Understand Modulus % Development Environment: csegrid (Centos), g++ (all students must use csegrid) Skills: declare variables, use operators Reading: Chap 2 and Chap 3 Deliverables: 1) This lab with 3 screen shots, 2) lastnameFirstLab02.cpp…
Goals:
Development Environment: csegrid (Centos), g++ (all students must use csegrid)
Skills: declare variables, use operators
Reading: Chap 2 and Chap 3
Deliverables: 1) This lab with 3 screen shots, 2) lastnameFirstLab02.cpp
Part I – Skills Practice (5 points)
mkdir lab02
cd lab02
nano augustinetLab02.cpp
#include <iostream> //needed for cin and cout
#include <string> //needed to use string
using namespace std; //needed for string and cin and cout
int main( )
{
double celsius, fahren;
int count;
string firstName, lastName; //use descriptive variable names
cout << “What is your first name?” << endl;
cin >> firstName;
cout << “What is your last name?” << endl;
cin >> lastName;
cout << “What is the fahrenheit temperature?\n”;
cin >> fahren;
celsius = (fahren – 32) * (5.0 / 9.0);
//make sure to use parenthesis
/*remember and int divided by int is an int
so you have to make it into a double with 5.0*/
cout << firstName << ” “ <<lastName
<<“, the Celsius temperature is “
<< celsius << endl;
return 0; //that is a zero not an Oh
}
g++ -o lab02 lastnamefirstlab02a.cpp
./lab02
Part II – Troubleshooting Common Problems (5 pts)
#include <iostream>
using namespace std;
int main()
{
int int1 = 5, int2 = 9, intResult;
double double1 = 5.0, double2 = 9.0, doubleResult;
const int SIZE = 10;
intResult = int1 / int2;//int divided by int is an int!
cout << int1 << “/” << int2 << “=” << intResult;
doubleResult = double1 / double2;//double divided by a double is a double
cout << double1 << “/” << double2 << “=” << doubleResult;
cout << “Division with one double and one int is a double\n”;
cout << “5/9.0 =” << 5 / 9.0 << endl;
cout << “5.0/9 =” << 5.0 / 9 << endl;
cout << “Convert an int to a double” << double(int1);
cout << “You can increment an int or double with ++:” << endl;
int1++;
cout << int1++ << endl;
cout << “But you can not change the value of a const”;
//take a screen shot of the error below then remove the statement
SIZE++;
return 0;
}
g++ -o lab2b lab02b.cpp
./lab02b
Part III – outline/pseudo-code/algorithms (5 pts)
Making Peanut Butter and Jelly Sandwiches
//Begin Main
//Ask Customer name
//Print “Spread peanut butter on bread”
//Print “Spread jelly on bread”
//End Main
Part IV -Employee pay rate implementation. (10 pts)
/* Name:
Class: CSCI 1411-00X
Description: [fill in description]
Lab Partner:
Status: successfully compiled and run on csegrid [if it doesn’t run or meet all of the requirements, list the actual status!/*
(See file for full code and next page for screenshot of application running)