Programming – Defining Variables (20 Points) Description: Develop a C++ program
ID: 3876657 • Letter: P
Question
Programming – Defining Variables (20 Points) Description: Develop a C++ program that uses variables and cout to output your first name, major, number of credit hours, and per credit hour tuition rate. Requirements: 1. Use 4 variables of the appropriate type initialized with the values for your name, major, credit hours and tuition rate. 2. Variable names must be descriptive 3. Use cout to output the values of the variables to the console. Your cout statement MUST use the 4 variables 4. Output must be labelled and easy to read as shown in the sample output below. 5. Program must be documented with the following: a. // Name b. // Date c. // Program Name d. // Description
Explanation / Answer
/*
Name : John (Replace John with your name)
Date : 19-Jan-2018
Program Name : Defining Variables
Description : Developing a C++ program that uses variables and cout to output your first name, major, number of credit hours, and per credit hour tuition rate
*/
#include <iostream>
using namespace std;
int main() {
// declaring variables
// **** Note: Please replace following values with whatever values you would like
string firstName = "John", major = "Computer Science";
int creditHours = 60;
double tutionRate = creditHours*200;
// printing the output
cout << "Name is " << firstName << endl;
cout << "Major is " << major << endl;
cout << "Credit Hours are " << creditHours << endl;
cout << "Tution Rate is " << tutionRate << endl;
}
/*SAMPLE output
Name is John
Major is Computer Science
Credit Hours are 60
Tution Rate is 12000
*/
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.