Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,047 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,553 people online right now. Registration is fast and FREE... Join Now!




Microsoft Visual C++ 6.0

 
Reply to this topicStart new topic

Microsoft Visual C++ 6.0, I have never written a program and do not know how in the world to use

rayjred
19 Jul, 2008 - 01:33 PM
Post #1

New D.I.C Head
*

Joined: 19 Jul, 2008
Posts: 10

I have already received a "D" on one assignment and now an "F" on another. I'm taking an online class, I'm deployed, I don't know how to use the program correctly and the instructor is not helping out any at all. When I explained to him I'm on deployment all he could say was if I weren't on deployment he would recommend I go into the school. My first thing is I need help on how to use Microsoft Visual C++ 6.0. I don't know how to compile or whatever it is I'm supposed to be doing. Than the next thing is what am I doing wrong in these two programs I tried to write? Here is the first. May be if I knew what I was doing wrong I could figure this thing out.

The University Bookstore sells 4 types of books: Accounting at $10, Business at $20, CIS at $30 and Drafting at $40. Write a program that computes the total sales. The program should ask the user for the number of each type of book sold, it then computes and displays the total amount for all the books sold.

For example; the program would ask:

Enter the number of Accounting books sold:
Enter the number of Business books sold:
Enter the number of CIS books sold:
Enter the number of Drafting books sold:

For each type of book it would multiply the number sold by the price to get the subtotal.
It would then sum all the subtotals to get the Total which is then displayed.

cpp
// prb01-1.cpp
// This program calculates the total charge for all books purchased

#include <iostream>
#include <iomanip>

Using namespace std;


// prb01-1.cpp
// This program calculates the total charge for all books purchased

#include <iostream>
#include <iomanip>

Using namespace std;

Int main()
{
// Declare the variables
int x, // Number of books sold
a1, // Price of accounting books
b2, // Price of business books
c3, // Price of cis books
d4, // Price of drafting books
subtotal, // Subtotal of a1 * x, b1 * x, c1 * x, d1 * x
sum, // sum of a1, b1, c1, d1
total; // Total of a1 + b1 + c1 + d1

// Obtain the input data

cout << "Enter the number of accounting books sold: ";
cin >> accounting;
cout << endl;

cout << "Enter the number of business books sold: ";
cin >> business;
cout << endl;

cout << "Enter the number of cis books sold: ";
cin >> cis;
cout << endl;

cout << "Enter the number of drafting books sold: ";
cin >> drafting;
cout << endl;

// Do the calculations

subtotal = a1 * x, b1 * x, c1 * x, d1 * x
sum = a1, b1, c1, d1
total = a1 + b1 + c1 + d1

// Display the results

cout << "Number of accounting books; " << endl;
cout << "Number of business books; " << endl;
cout << "Number of cis books; " << endl;
cout << "Number of drafting books; " << endl;
cout << "Subtotal of books; " << endl;
cout << "Sum of books; " << endl;
cout << "Total charge: << endl;

return 0;
}


and here is the second with the question.

Assignment 2 – Growth of an investment Account.
Write a program to estimate the total amount in an investment account over a 4 year period. The program requests the amount to be invested and the annual growth rate. For example the amount might be 2500.50 dollars and the growth rate may be 8% per year for the next 4 years. The program should display the estimated amount for each of the next 4 years.
NOTE
a) Change the entered rate to the corresponding decimal e.g. 8% = 8/100 = 0.08.
cool.gif Use += operator to increment the amount.

cpp

// as2rachal.cpp
// This program estimate the total amount in an investment account

#include <iostream>
#include <iomanip>

Using namespace std;

int main()
{
double invest, = //amount invested
growth, = //annual growth rate
total; = //total amount estimated over 4 years

cout << setprecision (2)
<< setiosflags (ios::fixed)
<< setiosflags (ios::showpoint);

cout << "Enter the investment amount for year 1: ";
cin << investment amount;
cout << "Enter the annual growth rate: ";
cin << annual growth rate;

invest *= growth
cout << "The growth is " << interest earned << endl;

total += investment += interest earned
cout << "The estimated total is " << total << endl;

// Obtain total amount from year 1 for year 2 investment amount

cout << "Enter the investment amount for year 2: ";
cin << investment amount;
cout << "Enter the annual growth rate: ";
cin << annual growth rate;

cout << "Enter the investment amount for year 2: ";
cin << investment amount;
cout << "Enter the annual growth rate: ";
cin << annual growth rate;

invest *= growth
cout << "The growth is " << interest earned << endl;

total += investment += interest earned
cout << "The estimated total is " << total << endl;

// Obtain total amount from year 2 for year 3 investment amount

cout << "Enter the investment amount for year 3: ";
cin << investment amount;
cout << "Enter the annual growth rate: ";
cin << annual growth rate;

cout << "Enter the investment amount for year 3: ";
cin << investment amount;
cout << "Enter the annual growth rate: ";
cin << annual growth rate;

invest *= growth
cout << "The growth is " << interest earned << endl;

total += investment += interest earned
cout << "The estimated total is " << total << endl;

// Obtain total amount from year 3 for year 4 investment amount

cout << "Enter the investment amount for year 4: ";
cin << investment amount;
cout << "Enter the annual growth rate: ";
cin << annual growth rate;

cout << "Enter the investment amount for year 4: ";
cin << investment amount;
cout << "Enter the annual growth rate: ";
cin << annual growth rate;

invest *= growth
cout << "The growth is " << interest earned << endl;

total += investment += interest earned
cout << "The estimated total is " << total << endl;

return 0;
}

User is offlineProfile CardPM
+Quote Post

markhazlett9
RE: Microsoft Visual C++ 6.0
19 Jul, 2008 - 01:56 PM
Post #2

D.I.C Head
**

Joined: 12 Jul, 2008
Posts: 160



Thanked: 10 times
My Contributions
One thing i might be able to point out to start( as i am just learning as well) Try and have your variable names without spaces. Such as investmentamount instead of "investment amount" Just one thing quick i could point out
User is online!Profile CardPM
+Quote Post

Martyr2
RE: Microsoft Visual C++ 6.0
19 Jul, 2008 - 02:12 PM
Post #3

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,198



Thanked: 212 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
hi rayjed,

First of all, you have to know that C++ is a case sensitive language. The word "Using" is not the same as "using". C++ will flag the first one as bad and the second as good. Keep this in mind ALWAYS! (same goes with "Int main" it is suppose to be "int main")

Next thing you made mistakes on are the ones that all new programmers tend to make. Bad variable names, too many variables, and not keeping variable names consistent through the program.

When making a variable ask yourself what purpose is this variable going to be for. Then name the variable with a good name that makes it very easy to read. If the variable is going to hold the number of accounting books sold, name the variable "accountingSold" makes sense right? It will help you, and others reading your code, remember what the variable is and when used in calculations it will almost sound like english sentences.

For instance totalSold = accountingSold + businessSold; would simply read "the total sold is equal to the number of accounting books sold plus business books sold"

You had a problem too about keeping variables straight. You had a1, b2, c3 defined but then tried to use "a1, b1, c1" which b1 and c1 are not defined. Using very good names will help you keep this straight too and prevent this error.

Then when you went to print the lines at the end, you didn't actually include the variables in the print lines so their values would never be displayed. So see how I did it below and that will help you.

Lastly, no where in the description did it say you needed a subtotal. So don't put anything in for that! You can simply calculate the total based on the number of books and their price. You would only need a subtotal if later they asked you to calculate tax.

Below is the first assignment redone (not bullet proof mind you because it does no error checking) but should give you an idea of how things are put together.

cpp

// prb01-1.cpp
// This program calculates the total charge for all books purchased

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
// Declare the variables
// Declare variables to hold number of books sold.
int accountingSold = 0, businessSold = 0, cisSold = 0, draftingSold = 0;

// Declare variables to hold the price of each type of book.
float a1 = 10.00, b2 = 20.00, c3 = 30.00, d4 = 40.00;

// Declare variable to hold the sum.
int sum = 0;

// Declare variable to hold the total.
float total = 0.00;

// Obtain the input data
// Collect the data and put the number into each of our books sold variables.
cout << "Enter the number of accounting books sold: ";
cin >> accountingSold;
cout << endl;

cout << "Enter the number of business books sold: ";
cin >> businessSold;
cout << endl;

cout << "Enter the number of cis books sold: ";
cin >> cisSold;
cout << endl;

cout << "Enter the number of drafting books sold: ";
cin >> draftingSold;
cout << endl;

// Do the calculations
// Books sold times price, added together for the total.
// Simply add together our sold variables to get the sum.

sum = (accountingSold + businessSold + cisSold + draftingSold);
total = (accountingSold * a1) + (businessSold * b2) + (cisSold * c3) + (draftingSold * d4);

// Display the results
// Notice how we put the variables into the lines to print their value.

cout << "Number of accounting books: " << accountingSold << endl;
cout << "Number of business books: " << businessSold << endl;
cout << "Number of cis books: " << cisSold << endl;
cout << "Number of drafting books: " << draftingSold << endl;
cout << "Sum of books: " << sum << endl;
cout << "Total charge: $" << total << endl;

return 0;
}


As for compiling, if you are doing simple C++ then you might want to switch to a compiler like Microsoft Visual C++ .NET 2008 Express edition. I find it a tad bit easier to use when creating standard C++ projects than back in version 6.0. That is a pretty old version and while it will work for C++, it is a bit harder to work with.

You can download visual c++ .net 2008 express for free (completely free) at the link below...

Microsoft Express Editions 2008

When creating a new project follow these steps...

1) Start up visual C++
2) On the left you will see "create project" Click that
3) In the window that pops up, go to "general" on the left tree
4) In the right pane you should then see "empty project" select that.
5) After the project starts up, you will again see a tree on the left in a pane called "solution explorer". Right click the folder that reads "source files"
6) A menu pops up and go to "Add >> new item"
7) In that window select "CPP file" and give it a name.
8) click ok
9) Now you will see a blank cpp file. Put your c++ code in there and hit the save icon.
10) Lastly, press ctrl + f5 to start the compiling. All errors in your code will appear as error messages in a window pane at the bottom of the screen. You can often times copy that text from the pane to the board here and we can help you diagnose the problems along with your code (which you should provide as well).

That is a basic idea of how you could compile your c++ programs and get running.

Hope this proves helpful to you. If it does, don't forget to select the "This post was helpful" link at the bottom.

Enjoy!

"At DIC we be c++ compiling code ninjas in .NET 2008 Exress, just don't get us pissed or we will 'express' our ideas in another way!" decap.gif
User is online!Profile CardPM
+Quote Post

F!st!cuffs
RE: Microsoft Visual C++ 6.0
19 Jul, 2008 - 02:23 PM
Post #4

D.I.C Head
**

Joined: 15 Jul, 2008
Posts: 55



Thanked: 2 times
My Contributions

http://www.cse.buffalo.edu/~bina/EAS230/fa...C++Tutorial.pdf


Here's a brief tutorial on vc++ 6.0 to tell you how to compile and what not.

This post has been edited by F!st!cuffs: 19 Jul, 2008 - 02:24 PM
User is offlineProfile CardPM
+Quote Post

rayjred
RE: Microsoft Visual C++ 6.0
19 Jul, 2008 - 02:34 PM
Post #5

New D.I.C Head
*

Joined: 19 Jul, 2008
Posts: 10

Martyr2,

Thanks for taking time out to explain that to me. This is the kind of response or input I wish my instructor would have given me besides just give me a grade back on the assignment, so I really do appreciate you taking time out to explain my mistakes and what I can do and how to use Microsoft Visual C++.

Question, if I download Microsoft Visual C++ .NET 2008 Express edition is it backwards compatible with Microsoft Visual C++ 6.0?

I ask because 6.0 came with the book and I'm not sure what the instructor is using.

QUOTE(Martyr2 @ 19 Jul, 2008 - 03:12 PM) *

hi rayjed,

First of all, you have to know that C++ is a case sensitive language. The word "Using" is not the same as "using". C++ will flag the first one as bad and the second as good. Keep this in mind ALWAYS! (same goes with "Int main" it is suppose to be "int main")

Next thing you made mistakes on are the ones that all new programmers tend to make. Bad variable names, too many variables, and not keeping variable names consistent through the program.

When making a variable ask yourself what purpose is this variable going to be for. Then name the variable with a good name that makes it very easy to read. If the variable is going to hold the number of accounting books sold, name the variable "accountingSold" makes sense right? It will help you, and others reading your code, remember what the variable is and when used in calculations it will almost sound like english sentences.

For instance totalSold = accountingSold + businessSold; would simply read "the total sold is equal to the number of accounting books sold plus business books sold"

You had a problem too about keeping variables straight. You had a1, b2, c3 defined but then tried to use "a1, b1, c1" which b1 and c1 are not defined. Using very good names will help you keep this straight too and prevent this error.

Then when you went to print the lines at the end, you didn't actually include the variables in the print lines so their values would never be displayed. So see how I did it below and that will help you.

Lastly, no where in the description did it say you needed a subtotal. So don't put anything in for that! You can simply calculate the total based on the number of books and their price. You would only need a subtotal if later they asked you to calculate tax.

Below is the first assignment redone (not bullet proof mind you because it does no error checking) but should give you an idea of how things are put together.

cpp

// prb01-1.cpp
// This program calculates the total charge for all books purchased

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
// Declare the variables
// Declare variables to hold number of books sold.
int accountingSold = 0, businessSold = 0, cisSold = 0, draftingSold = 0;

// Declare variables to hold the price of each type of book.
float a1 = 10.00, b2 = 20.00, c3 = 30.00, d4 = 40.00;

// Declare variable to hold the sum.
int sum = 0;

// Declare variable to hold the total.
float total = 0.00;

// Obtain the input data
// Collect the data and put the number into each of our books sold variables.
cout << "Enter the number of accounting books sold: ";
cin >> accountingSold;
cout << endl;

cout << "Enter the number of business books sold: ";
cin >> businessSold;
cout << endl;

cout << "Enter the number of cis books sold: ";
cin >> cisSold;
cout << endl;

cout << "Enter the number of drafting books sold: ";
cin >> draftingSold;
cout << endl;

// Do the calculations
// Books sold times price, added together for the total.
// Simply add together our sold variables to get the sum.

sum = (accountingSold + businessSold + cisSold + draftingSold);
total = (accountingSold * a1) + (businessSold * b2) + (cisSold * c3) + (draftingSold * d4);

// Display the results
// Notice how we put the variables into the lines to print their value.

cout << "Number of accounting books: " << accountingSold << endl;
cout << "Number of business books: " << businessSold << endl;
cout << "Number of cis books: " << cisSold << endl;
cout << "Number of drafting books: " << draftingSold << endl;
cout << "Sum of books: " << sum << endl;
cout << "Total charge: $" << total << endl;

return 0;
}


As for compiling, if you are doing simple C++ then you might want to switch to a compiler like Microsoft Visual C++ .NET 2008 Express edition. I find it a tad bit easier to use when creating standard C++ projects than back in version 6.0. That is a pretty old version and while it will work for C++, it is a bit harder to work with.

You can download visual c++ .net 2008 express for free (completely free) at the link below...

Microsoft Express Editions 2008

When creating a new project follow these steps...

1) Start up visual C++
2) On the left you will see "create project" Click that
3) In the window that pops up, go to "general" on the left tree
4) In the right pane you should then see "empty project" select that.
5) After the project starts up, you will again see a tree on the left in a pane called "solution explorer". Right click the folder that reads "source files"
6) A menu pops up and go to "Add >> new item"
7) In that window select "CPP file" and give it a name.
8) click ok
9) Now you will see a blank cpp file. Put your c++ code in there and hit the save icon.
10) Lastly, press ctrl + f5 to start the compiling. All errors in your code will appear as error messages in a window pane at the bottom of the screen. You can often times copy that text from the pane to the board here and we can help you diagnose the problems along with your code (which you should provide as well).

That is a basic idea of how you could compile your c++ programs and get running.

Hope this proves helpful to you. If it does, don't forget to select the "This post was helpful" link at the bottom.

Enjoy!

"At DIC we be c++ compiling code ninjas in .NET 2008 Exress, just don't get us pissed or we will 'express' our ideas in another way!" decap.gif


User is offlineProfile CardPM
+Quote Post

F!st!cuffs
RE: Microsoft Visual C++ 6.0
19 Jul, 2008 - 02:42 PM
Post #6

D.I.C Head
**

Joined: 15 Jul, 2008
Posts: 55



Thanked: 2 times
My Contributions
As for opening vc projects you can't open 2008 projects in the 6.0 IDE but you can just send your teacher the source code that you write and she can compile it or send the source and the working exe so she can run it and look at what you've written.
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Microsoft Visual C++ 6.0
19 Jul, 2008 - 03:06 PM
Post #7

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,198



Thanked: 212 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
From the looks of it you are learning straight C++ so it doesn't matter which compiler you use since both compilers handle C++. The only problem you would have is if you were using VC 6.0 features which I don't see you doing since you are very basic right now.

So if your book is for C++ beginners, then anything in your book should work in express 2008 just fine. You can ask your instructor if 2008 express would work for all your examples.

Either way you could keep vc 6.0 installed and install express along with it and if you find you need to go back to vc 6.0 for a project, then you can deal with compiling in that at that time.

I thought I would bring up that compiler because I find it very easy to use and simple and may be nice for someone who is a beginner. But talk to your instructor and see what they say. smile.gif

Good luck with the projects.
User is online!Profile CardPM
+Quote Post

rayjred
RE: Microsoft Visual C++ 6.0
19 Jul, 2008 - 05:29 PM
Post #8

New D.I.C Head
*

Joined: 19 Jul, 2008
Posts: 10

Sorry it took so long to respond back. I had to take a break because I had been at it for a while. Thanks again Martyr2. I wish I knew about this site when I first started the class.

I would also like to say thanks to F!st!cuffs and markhazlett9. Thank you all and I'm sure I will be posting for help again in the very near future. I'm going to give this weeks problem a world and see how it goes. I'll keep you guys posted. You guys are awesome, thanks.

Ray

QUOTE(Martyr2 @ 19 Jul, 2008 - 04:06 PM) *

From the looks of it you are learning straight C++ so it doesn't matter which compiler you use since both compilers handle C++. The only problem you would have is if you were using VC 6.0 features which I don't see you doing since you are very basic right now.

So if your book is for C++ beginners, then anything in your book should work in express 2008 just fine. You can ask your instructor if 2008 express would work for all your examples.

Either way you could keep vc 6.0 installed and install express along with it and if you find you need to go back to vc 6.0 for a project, then you can deal with compiling in that at that time.

I thought I would bring up that compiler because I find it very easy to use and simple and may be nice for someone who is a beginner. But talk to your instructor and see what they say. smile.gif

Good luck with the projects.


User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 05:17PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month