473,625 Members | 2,662 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

i need some help with these errors that i am getting on my program.....

6 New Member
any help would be appreciated. here is my code:


Expand|Select|Wrap|Line Numbers
  1. // Final Project
  2.  
  3. #include <iostream.h>
  4. #include <iomanip.h>        
  5.  
  6. void checkout();
  7. void start_or_startover();
  8. void receipt();
  9.  
  10. float subtotal, tax, total;
  11.  
  12. // Prices
  13. float laptopprice = 799.99;
  14. float mouseprice = 12.99;
  15. float keyboardprice = 29.99;
  16. float moniterprice = 399.99;
  17. float usbprice = 16.99;
  18. float hdmiprice = 24.99;
  19. float lazerprice = 6.99;
  20. float powerprice = 9.99;
  21.  
  22. // Quantity
  23. int laptopnumber;
  24. int mousenumber;
  25. int keyboardnumber;
  26. int moniternumber;
  27. int usbnumber;
  28. int hdminumber;
  29. int lazernumber;
  30. int powernumber;
  31.  
  32. // Main Function
  33. int main()
  34. {
  35.     do
  36.     { start_or_startover(); }
  37.     while (choice == 10);
  38.  
  39.     receipt();
  40.  
  41.     return 0;
  42. }
  43.  
  44. {
  45.     cout << "Ferger's Technology Store" << endl << endl;
  46.  
  47.  
  48.     do
  49.     {
  50.     cout << "(1) HP Pavilion Intel Core 2 Duo Laptop        $799.99" << endl;
  51.     cout << "(2) Razer Black Wired Lazer Mouse                $12.99" << endl;
  52.     cout << "(3) Razer Keyboard Wired                        $29.99" << endl;
  53.     cout << "(4) HP LCD Flatscreen Moniter                    $399.99" << endl;
  54.     cout << "(5) SATA USB 8GB Flash Drive                    $16.99" << endl;
  55.     cout << "(6) HDMI Full 1080p 6ft Cable                    $24.99" << endl;
  56.     cout << "(7) Lazer Pointer                                $6.99" << endl;
  57.     cout << "(8) Power Cord                                    $9.99 << endl;
  58.     cout << "endl;
  59.         cout << "(9) Total" << endl;
  60.     cout << "(10) Cancel Order" << endl;
  61.     cout << " Please enter the choice number of the electronics that you would like to buy." << endl << endl;
  62.     cin >> choice;
  63.     cout << endl;
  64.  
  65.     if (choice == 9)
  66.     {
  67.         chechout();
  68.     }
  69.     if (choice == 1 || choice == 2 || choice == 3 || choice == 4 || choice == 5 || choice == 6 || choice == 7 || choice == 8)
  70.     {
  71.     cout << " How many would you like? ";
  72.     cin >> choice_amount;
  73.     cout << endl;
  74.  
  75.     if (choice == 1)
  76.     {
  77.         laptopnumber = choice_amount;
  78.     }
  79.  
  80.     if (choice == 2)
  81.     {
  82.         mousenumber = choice_amount;
  83.     }
  84.  
  85.     if (choice == 3)
  86.     {
  87.         keyboardnumber = choice_amount;
  88.     }
  89.  
  90.     if (choice == 4)
  91.     {
  92.         moniternumber = choice_amount;
  93.     }
  94.  
  95.     if (choice == 5)
  96.     {
  97.         usbnumber = choice_amount;
  98.     }
  99.  
  100.     if (choice == 6)
  101.     {
  102.         hdminumber = choice_amount;
  103.     }
  104.     if (choice == 7)
  105.     {
  106.         lazernumber = choice_amount;
  107.     }
  108.     if (choice == 8)
  109.     {
  110.         powernumber = choice_amount;
  111.     }
  112.     }
  113.  
  114.     if (choice == 10)
  115.     {
  116.         laptopnumber = 0;
  117.         mousenumber = 0;
  118.         keyboardnumber = 0;
  119.         moniternumber = 0;
  120.         usbnumber = 0;
  121.         hdminumber = 0;
  122.         lazernumber = 0;
  123.         powernumber = 0;
  124.     }
  125.     }
  126.     while (choice != 9);
  127.     }
  128.  
  129. {
  130.     subtotal = (laptopnumber * laptopprice) + (mousenumber * mouseprice) + (keyboardnumber * keyboardprice) + (    subtotal = (laptopnumber * laptopprice) + (mousenumber * mouseprice) + (keyboardnumber * keyboardprice) + (    subtotal = (laptopnumber * laptopprice) + (mousenumber * mouseprice) + (keyboardnumber * keyboardprice) + (moniternumber * moniterprice) + (usbnumber * usbprice) + (hdminumber * hdmiprice) + (lazernumber * lazerprice) + (powernumber * powerprice);
  131.  
  132.     tax = subtotal * .0875;
  133.  
  134.     total = subtotal + tax;
  135. }
  136. void receipt()
  137. {
  138.     cout << "Thank you for your buisness. Here is your recipt." << endl << endl;
  139.     cout.setf(ios::fixed);
  140.     cout << "Items\t\t  " << "Number of items purchased \t Price of each item \t Total price" << endl;
  141.     cout << "HP Pavilion Intel Core 2 Duo Laptop \t "<< laptopnumber << "\t\t\t" << "$" << setprecision(2) << laptopprice << "\t\t   " << "$" << (laptopnumber * laptopprice) << endl;
  142.     cout << "Razer Black Wired Lazer Mouse \t "<< mousenumber << "\t\t\t" << "$" <<  mouseprice << "\t\t   " << "$" << (mousenumber * mouseprice) << endl;
  143.     cout << "Razer Keyboard Wired \t "<< keyboardnumber << "\t\t\t" << "$" << keyboardprice << "\t\t   " << "$" << (keyboardnumber * keyboardprice) << endl;
  144.     cout << "SATA USB 8GB Flash Drive \t "<< usbnumber << "\t\t\t" << "$" << usbprice << "\t\t   " << "$" << (usbnumber * usbprice) << endl;
  145.     cout << "HDMI Full 1080p 6ft Cable \t "<< hdminumber << "\t\t\t" << "$" << hdmiprice << "\t\t   " << "$" << (hdminumber * hdmiprice) << endl;
  146.     cout << "Lazer Pointer \t "<< lazernumber << "\t\t\t" << "$" << lazerprice << "\t\t   " << "$" << (lazernumber * lazerprice) << endl;
  147.     cout << "Power Cord \t "<< powernumber << "\t\t\t" << "$" << powerprice << "\t\t   " << "$" << (powernumber * powerprice) << endl;
  148.  
  149.     cout << "\t\t Subtotal \t $" << subtotal << endl;
  150.     cout << "\t\t Tax \t\t $" << tax << endl;
  151.     cout << "\t\t Total \t\t $" << total << endl << endl << endl;
  152. }
  153.  
and here is the errors that i am getting:

--------------------Configuration: finalproject - Win32 Debug--------------------
Compiling...
finalproject.cp p
H:\finalproject .cpp(14) : warning C4305: 'initializing' : truncation from 'const double' to 'float'
H:\finalproject .cpp(15) : warning C4305: 'initializing' : truncation from 'const double' to 'float'
H:\finalproject .cpp(16) : warning C4305: 'initializing' : truncation from 'const double' to 'float'
H:\finalproject .cpp(17) : warning C4305: 'initializing' : truncation from 'const double' to 'float'
H:\finalproject .cpp(18) : warning C4305: 'initializing' : truncation from 'const double' to 'float'
H:\finalproject .cpp(19) : warning C4305: 'initializing' : truncation from 'const double' to 'float'
H:\finalproject .cpp(20) : warning C4305: 'initializing' : truncation from 'const double' to 'float'
H:\finalproject .cpp(21) : warning C4305: 'initializing' : truncation from 'const double' to 'float'
H:\finalproject .cpp(38) : error C2065: 'choice' : undeclared identifier
H:\finalproject .cpp(45) : error C2447: missing function header (old-style formal list?)
H:\finalproject .cpp(58) : error C2001: newline in constant
H:\finalproject .cpp(59) : error C2001: newline in constant
H:\finalproject .cpp(130) : error C2447: missing function header (old-style formal list?)
Error executing cl.exe.

finalproject.ob j - 5 error(s), 8 warning(s)
Jan 14 '10 #1
5 1938
weaknessforcats
9,208 Recognized Expert Moderator Expert
Expand|Select|Wrap|Line Numbers
  1. H:\finalproject.cpp(14) : warning C4305: 'initializing' : truncation from 'const double' to 'float'
This means that symbolic constants (like 12.99) are doubles but your variable is a float. You are being warned that the value in the double may lose accuracy when converted to a float. Recommendation: Never use float. Stick with double unless you can bwrite down on paper the technical reason why it has to be a float.

H:\finalproject .cpp(38) : error C2065: 'choice' : undeclared identifier
Here you refer to a variable (choice) that you have never defined.

H:\finalproject .cpp(45) : error C2447: missing function header (old-style formal list?)
Your braces are out of balance. Be sure you have matching {} pairs.

H:\finalproject .cpp(58) : error C2001: newline in constant
Here a constant is missing a ".

H:\finalproject .cpp(130) : error C2447: missing function header (old-style formal list?)
Again your braces are out of balance.

Te exact line number where the compiler got into trouble is in the error.
Jan 14 '10 #2
qwert7465
6 New Member
sorry to ask another question, but to be specific, what should i do exactly? im not really good with this programming thing and i would greatly appreciate specifically what to do :)
Jan 14 '10 #3
weaknessforcats
9,208 Recognized Expert Moderator Expert
Change your float variables to double.

Verify every one of you { has a matching }. Remember, this error can make a function look like it is written inside another function:

Expand|Select|Wrap|Line Numbers
  1. void Function1()
  2. {
  3. <-------------missing }
  4. void Function2()
  5. {
  6.  
  7. }
Make sure every " has a matching " on the same line:

Expand|Select|Wrap|Line Numbers
  1. cout << "hello
  2.             world!";
should be:
Expand|Select|Wrap|Line Numbers
  1. cout << "Hello"
  2.             " world";
or
Expand|Select|Wrap|Line Numbers
  1. cout << "Hello world";
In any case, the procedure is to fix the first error/warning and then rebuild. Then fix the first error again. Often later errrors are the result of previous errors.
Jan 14 '10 #4
qwert7465
6 New Member
i did what you said about the " and the matching " but the part with { and the matching }, i cant find where to put the other one. when i put in another one after my int main() i get a ton of errors requiring ;.
Jan 14 '10 #5
weaknessforcats
9,208 Recognized Expert Moderator Expert
You have to go thriugh the code carefully and make sure your {} are paired up correctly.

Here's the first problem:

Expand|Select|Wrap|Line Numbers
  1. int main() 
  2.     do 
  3.     { start_or_startover(); } 
  4.     while (choice == 10); 
  5.  
  6.     receipt(); 
  7.  
  8.     return 0; 
  9. }     <<<<<<<<< end of main()
  10.  
  11. {     <<<<<<<<<<<<what's this for?
  12.     cout << "Ferger's Technology Store" << endl << endl; 
Jan 14 '10 #6

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

Similar topics

0
1681
by: Henry Reardon | last post by:
I just installed DB2 Personal Developer's Edition V8.2 (FP7) over my old DB2 V7.2 instance but I'm having some problems. Can anyone help? The first problem is that my migration didn't go too well. I got this during the setup wizard: The migration of the instance "DB2" has failed. The return value is "-2". When I looked at the databases in the Control Center, they all seemed to be there, including the ones created during the install...
2
2112
by: Erik | last post by:
Hi Everyone, I'm having real problems compiling some source for eVC4++. The errors I am getting are below: It all seems to be centred around winsock. If I move the afsock.h reference to before my other includes then I get lots of errors like C2011: 'fd_set' : 'struct' type redefinition warning C4005: 'FD_CLR' : macro redefinition which I understand are due to the fact that windows.h is being included in another header file as well as...
11
2390
by: DrNoose | last post by:
Hi! I've got a program that's almost done, but I'm getting compile errors in two lines: 317 & 319. I think the main error has to do with the Truck Class. I'm a newbie and keep looking at the code but can't seem to see the error. I don't understand a lot of the fancy stuff so if you can keep it simple for me!!!! Any help is appreciated! Here is the code:
66
5334
by: genestarwing | last post by:
QUESTION: Write a program that opens and read a text file and records how many times each word occurs in the file. Use a binary search tree modified to store both a word and the number of times it occurs. After the program has read the file, it should offer a menu with three choices. the first is to list all the words along with the number of occurences. The second is to let you enter a word, with the program reporting how many times the...
8
2735
by: skumar434 | last post by:
i need to store the data from a data base in to structure .............the problem is like this ....suppose there is a data base which stores the sequence no and item type etc ...but i need only the sequence nos and it should be such that i can access it through the structure .plz help me .
0
2530
by: Pucca | last post by:
Hi I'm using vs2005. I am getting a bunch of compiler warnings after I made some changes to my code that was compiling clean. I'm also getting memory errors when I run my program and it's pinvoking some C++ code, which was working also fine before. I wonder if these warning are causing the problem. I would appreciate some help or suggestions on how to correct these. Thanks. Warning 37 At least one of the arguments for...
0
1148
by: alfie27 | last post by:
Hi, I am getting 2 errors when i try to run my program. This is my first time using the struct feature so i'm not sure how to correct my errors. Any help will be greatly appreciated. Here are the errors i am getting : error C2440: 'initializing' : cannot convert from 'Transaction_structure ' to 'Transaction_structure *' error C2664: 'transact' : cannot convert parameter 1 from 'Transaction_structure ' to 'Transaction_structure &' ...
3
5608
by: sunbeam | last post by:
Short Description of the Project: we developed a e-learning system for our students. each student has a unique username/password to view the modules he/she should view and nothing more. since we want to give them the opportunity to run these modules from home as well, we are trying to get the USERNAME/COMPUTERNAME as well, so the students, when they sign up for the modules, they can ONLY run the modules fromhome PC. We found a nice...
46
2509
by: Bruce W. Darby | last post by:
This will be my very first VB.Net application and it's pretty simple. But I've got a snag in my syntax somewhere. Was hoping that someone could point me in the right direction. The history: My work involves creating custom packages of our software product for golf courses that purchase our software. The course data is kept as a back up in the event the course needs us to replace their custom files. Each course has a folder of it's own...
0
8251
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8182
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8635
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8352
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
4085
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2614
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1800
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1496
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.