473,394 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Mayday, mayday

I am trying to write this short program that will calculate, (1) the cost for hotel (45 a night), cost for gas (1.67 a gallon) and total cost. The car is going to be used for a total of 200 and it already 20 miles on it. I know that 200/20*1.67 is the correct formula but how would I get the visual 6.00C++ to recognize it.
Here is what I have so far:

#include<iostream>
#include<iomanip>

using namespace std;

int main()

{
int num
int destination;
double total;
const double hotel = 45.00


cout<<"Welcome to Oscar Vacation Planner!\n"<<endl;
cout<<"Please enter destination distance"<<endl;
cin>> destination;

cout<<"Enter your cars mileage"<<endl;
cin>> mileage;

cout<<"Enter cost of gas per gallon"<<endl;
cin>> gas;


cout<<"How many days are you staying"<<endl;
total = hotel * 2;

total = destination * mileage /gas;
total = hotel * 2;

/*
gas 1.67
hotel 45.00

*/





cout<< fixed<<showpoint;
cout<<setprecision(2);




cout<<setw(20)<<"Total:";
cout<<setw(10)<<total<<endl;

return 0;
}
Sep 20 '06 #1
2 1822
Banfa
9,065 Expert Mod 8TB
You want to add your 2 totals

Expand|Select|Wrap|Line Numbers
  1. cout<<"How many days are you staying"<<endl;
  2. total = hotel * 2;  // <-- oops number of days hard coded to 2
  3.  
  4. total = destination * mileage /gas;  // <-- This overwrites the hotel total
  5. total = hotel * 2;      // <-- This overwrites the car total
  6.  
You need to add the totals instead like this

Expand|Select|Wrap|Line Numbers
  1. int days;  // Put this at the top of the function
  2.  
  3. cout<<"How many days are you staying"<<endl;
  4. cin >> days;
  5. total = hotel * days;
  6.  
  7. total += destination * mileage /gas;  // Add car total onto hotel total
  8.  
Sep 21 '06 #2
I have added the set of code you gave me and along with my code. I am still getting a error message. This is the new error I am receiving, and it is the only one. Can you please take a look at it.



C:\Program Files\Microsoft Visual Studio\MyProjects\webscript\banta.cpp(7) : error C2447: missing function header (old-style formal list?)


You want to add your 2 totals

Expand|Select|Wrap|Line Numbers
  1. cout<<"How many days are you staying"<<endl;
  2. total = hotel * 2;  // <-- oops number of days hard coded to 2
  3.  
  4. total = destination * mileage /gas;  // <-- This overwrites the hotel total
  5. total = hotel * 2;      // <-- This overwrites the car total
  6.  
You need to add the totals instead like this

Expand|Select|Wrap|Line Numbers
  1. int days;  // Put this at the top of the function
  2.  
  3. cout<<"How many days are you staying"<<endl;
  4. cin >> days;
  5. total = hotel * days;
  6.  
  7. total += destination * mileage /gas;  // Add car total onto hotel total
  8.  
Sep 22 '06 #3

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

Similar topics

4
by: Mathew | last post by:
Hi, I've got a problem and I haven't found any solution in the web till now. I'm using MSXML4.0SP2 with VC6 creating large XML files. The (only) problem I've got is the not-existing release of...
5
by: Ouwet5775 | last post by:
Hello peeps. Well i have tried runing the folwoing program several times, and i cant figure out what i am doing wrong. The goal of this is to input values for an array, find the maximum and the...
3
kickingthehabbit
by: kickingthehabbit | last post by:
Hi All new to all of this I just downloaded reactor server. everything works fine except Mysql - SQL import files. I am trying to import file createdb.sql I open DB and try and import with...
3
by: skulkrinbait | last post by:
I've a HTML form that allows a user to specify the location to upload a file from: <p><label for = 'file'>Upload Graphics : <input type='file' name='imagefile' /></label></p> I then want to...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.