473,471 Members | 2,175 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

C++ saving, if problem

1 New Member
I wrote this C++ code and the first part ran up until the variable 'weekhours'. Now I saved it and reopened it and it wont compile or run at all. I dont understand this. I also did not understand why the program stopped halfway through when it did work and didnt do any of the if statement, though it looks like it should run to me. I defined all the variables. Can anyone help me out?

Expand|Select|Wrap|Line Numbers
  1. #include<iostream.h>
  2.  
  3.  
  4. int main()
  5. {
  6.     float dayonehours, dayonewage, dayonetotal, daytwohours, daytwowage, daytwototal, daythreehours, daythreewage, 7daythreetotal, totalweek, weekhours;
  7.  
  8.     cout<< "Please type in Day 1 hours: ";
  9.     cin >> dayonehours;
  10.     cout << "Please type in hourly wage: ";
  11.     cin >> dayonewage;
  12.     dayonetotal = (dayonewage*dayonehours);
  13.     cout << " Total amount earned for " << dayonehours << " hours is $ " << dayonetotal << endl;
  14.  
  15.  
  16.     cout<< "Please type in Day 2 hours: ";
  17.     cin >> daytwohours;
  18.     cout << "Please type in hourly wage: ";
  19.     cin >> daytwowage;
  20.     daytwototal = (daytwowage*daytwohours);
  21.     cout << " Total amount earned for " << daytwohours << " hours is $ " << daytwototal << endl;
  22.  
  23.     cout << "Please type in Day 3 hours: ";
  24.     cin >> daythreehours;
  25.     cout << "Please type in hourly wage: ";
  26.     cin >> daythreewage;
  27.     daythreetotal = (daythreewage*daythreehours);
  28.     cout << " Total amount earned for " << daythreehours << " hours is $ " << daythreetotal << endl;
  29.  
  30.     weekhours=(dayonehours+daytwohours+daythreehours);
  31.     cout<< "Total hours worked for the week is "<<weekhours<<endl;
  32.  
  33.     weektotal=(dayonetotal+daytwototal+daythreetotal);
  34.     cout<<"The total earned for the week is $"<<weektotal<<endl;
  35.  
  36.     if(weektotal>150.00)
  37.     cout<< "Go to see a movie Saturday evening; and have a good dinner in favorite eatery.\n';
  38.  
  39.     else if(weektotal<=150.00 & weektotal>100.00)
  40.     cout<< "Go to see movie Saturday afternoon; Have a hamburger for dinner at Mcdonald.\n"
  41.     else if(weektotal<100)
  42.     cout<<"Watch football game UM vs. MSU at home; and have a home-made sandwich.\n"
  43.     else
  44.     cout<<"No TV/movie over weekend"<<endl;
  45.  
  46.     if(weekhours>15.0)
  47.     cout<<"No Tv/movie or weekend"<<endl;
  48.  
  49.  
  50.     system("pause")
  51.     return 0;
  52. }
Oct 4 '07 #1
1 1096
sicarie
4,677 Recognized Expert Moderator Specialist
Well, you should be using <iostream> and not <iostream.h>, as well as adding 'using namespace std;' right after.

So the first time you ran it, it only would execute half way through the program? Were there errors? What does it do now? Does it print anything?
Oct 5 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Lovely Angel For You | last post by:
Dear Friends Hope you all doing great. I have this problem. When I try to save any ASP page, I get the message that "The page will not save correctly". Even though I go ahead and when I go...
7
by: G-Factor | last post by:
Hi all I've just started learning about saving files. I got bit of a problem. The following code gives me an error about incompatible types. (Cannot covert from class character to char *). I...
4
by: Michael Kennedy [UB] | last post by:
Hi Everyone, I have this multithreaded C# windows forms application which does a lot of image processing. Occasionally, I get the following error: A generic error occurred in GDI+....
2
by: manning_news | last post by:
Has anyone had a problem with Access 2003 not saving their coding? I've been using 2003 for a couple of months now and just this week noticed that some coding I'd done for a database was not there...
2
by: Peder Y | last post by:
My code is something like this: --------------- Image img = Image.FromFile("somefile.bmp"); FileStream fStream = new FileStream("someBinaryFile.dat"); BinaryWriter bw = new...
4
by: Pedro Leite | last post by:
Good Afternoon. the code below is properly retreiving binary data from a database and saving it. but instead of saving at client machine is saving at the server machine. what is wrong with my...
6
by: Mark Denardo | last post by:
My question is similar to one someone posted a few months back, but I don't see any replies. Basically I want to be able to have users upload photos and save them in a database (as byte data)...
2
by: =?Utf-8?B?bWFydGluMQ==?= | last post by:
Hi, All, My app picks ccurrent time on the PC to retrieve data from sql DB, the Sql data is always data with non-daylight saving. The app runs on PC with both daylight saving and non-daylight...
9
by: Wingot | last post by:
Hey, I am using Visual Studio 2008 Beta 2 for some application development in C#, but I presume that the following question applies equally well to any environment.
1
by: Charming12 | last post by:
Hi All, I am facing quite a unique problem here with DayLight saving time. I know Windows handles Daylight saving time internally to sync PC Clock . But now i need to pass the Information of...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.