Exercise #1
Enter the following program into the Visual Studio .NET environment. Save it as a source file on the C: disk (replacing "your name" with your own name and replacing the words "description in your own words" with your own description of what the program does). I recommend making a folder to hold your program files; choose some name you will remember for the folder. Name the source file yourname-ex1.cpp where "yourname" is replaced with your last name - I would name my source file wolfe-ex1.cpp. Compile, link, and execute the program. Note: you will get a warning message when you compile (and probably two warnings when you link).
// your name
// 18 January 2008
// description in your own words
#include <iostream>
using namespace std;
const double DEBT = 500.00;
// Amount owed
const double PAYMENT = 45.76;
// Payment amount
const double INTEREST = 0.0247;
// Interest rate
int main()
{
double charge;
// Interest part of payment
float reduction;
// Amount the debt is reduced
double remain;
// Amount still owed
charge = INTEREST * DEBT;
reduction = PAYMENT - charge;
remain = DEBT - reduction;
cout << "Payment: $" <<
PAYMENT
<<
" Interest charge: $" << charge
<<
" Balance owed: $" << remain << endl;
return 0;
}
When you are finished, copy the .cpp file to the Z: disk; put it in the folder
Z:\jlwolfe\cosc110\secX\ex1\
where "secX" is either sec1 or sec2 depending
on your section. Do NOT try to do this copying from the Visual
Studio environment - close the solution and use Windows Explorer or My
Computer to do the copying. Then, go back to the program (restart
the Visual C++ environment, if necessary) and try to make a change which
will eliminate the warning message that you received when compiling.
Also, see what happens when you leave the << endl
out of the second to last line. (You still need the semicolon at
the end.)