Another C++ program

Posted on 2013-09-16
Medium Priority
Last Modified: 2013-09-19
Write a program that reads the data in a text file of ticket prices and number of tickets sold, calculating the number of tickets sold and total sales amount.

I have the numbers in notepad saved to use.
Question by:Tammaria
  • 3
  • 2
LVL 36

Accepted Solution

mccarl earned 2000 total points
ID: 39498461
Is this homework?

Please post the work that you have already done and what SPECIFIC problems you are having with it.

Author Comment

ID: 39501278
I had saved the problem to my Document folder and put it my compiler. I was having a problem with it running in my VS Express compiler. I got with one of my classmates and she showed me what the problem was. The compiler was saying that the library was "deprecated". I had to go to the source file and add to open it up to put in my program and ran it from there. I thought I was doing something wrong in my program but it was not. Sorry for the confusion. I can send you the copy of my program if I need to. Thank you.
LVL 37

Expert Comment

ID: 39501356
I imagine that at this point in the class you don't need to be linking libraries. You should probably be using a Win32 Console application and 'Empty Project' so that all it uses is your c++ code and it doesn't try to wrap its own libraries around everything.
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.


Author Closing Comment

ID: 39502604
I have it fixed now. When I ran my program on my computer I was having multiple error messages. Then when I took it to school, which wasn't until yesterday, I ran it on their computer and it worked without errors. It was in my compiler. It is not homework but work we did in class that the instructor put onto the board and we put into our compilers. I could not figure out why it was running with errors but it is not now. Thank you for your assistance.

Author Comment

ID: 39504535
The linking libraries was part of the issue. I had to go into the Source File and add new to pull the compiler to get my program to run. I have my program attached. It did the output like it was supposed to but did show a negative on the second set of numbers. I do not think it was supposed to do this. Take a look at it and see what I may have wrong. The information was given to us by my professor so it should be correct but puts out a negative amount.
LVL 37

Expert Comment

ID: 39505880
You set it up to display decimals, but then you only used ints. That seems odd.

The negative numbers are clearly wrong. It shows negative for all of them?
My guess is that the text file did not open. Make sure you check that it opened properly before you use it (your notes or book will show you the way your professor wants you to do it). Also, are you sure it's a good idea to hard code four of the same blocks of code like that? What if the text file had 20 lines instead of 4? If your grader has any sense of dignity, he will count off a lot of points. You should be using your file I/O techniques to see when you reached the end of the file or at least use a for loop.

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
No other job is as rewarding and demanding as building an iPhone app is. It is not really in the hands of the developer for the success of an iPhone app. Many factors operate jointly for every iOS application's success in the market.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Screencast - Getting to Know the Pipeline

586 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question