C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 24th, 2012, 07:49 PM
notaprogrammer notaprogrammer is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 2 notaprogrammer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 58 sec
Reputation Power: 0
Newby needs help with simple program

Trying to write a program where it calculates the cost of a car with a selected option package. 4 hours into it and I am about to go insane. Here's that assignment:

Input a base price
Input an option package code (2 letter code)
Subtotal
Apply 15% tax
Attach package code to a package name
Display package name and total price

use loops, parallel arrays
No functions

Is anyone interested in helping me? Below is my code so far, which doesn't get me far.

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

int main()
{

//Declare arrays and variables
char optionPackageCodeArray [5] = {'BB','SP','NP','HE','UC'};
double packageCostArray [5] = {1500,3250,4575,7500,5220};
string packageNameArray [5] = {'Base','Sport','Intermediate level','Luxury','User Specified'};

double basePrice = 0.0;
double packageCost = 0.0;
double subTotal = 0.0;
double taxCost = 0.0;
double totalCost = 0.0;
char packageName = ' ';
char optionPackageCode = ' ';
char searchIndex = ' ';
int sub = 0;

//Prompt user for base price and option code
cout<<"Enter the Base Price: $";
cin>> basePrice;
cout<<"Enter the Option Code:";
cin>>optionPackageCode;


//Find the optionPackageCode
while (sub < 5 && optionPackageCodeArray[sub] != optionPackageCode)
sub +=1;
//end while

//Associate the optionPackageCode with the packageCost
if (sub < 5)
cout << "Option Cost is: $" <<packageCost[sub]<<endl;
else
cout << "Invalid Code" <<endl;
//end if


subTotal = basePrice + packageCost;
totalCost = subTotal * 1.15;

//Display total cost of car with options and tax
cout<<endl;
for(char displayIndex = 0; displayIndex <5; displayIndex++)
cout<<"Your final cost with the "<<packageName<<" is: $"<<totalCost<<endl;

system("pause");
return 0;
} //end of main

Reply With Quote
  #2  
Old October 24th, 2012, 08:22 PM
G4143 G4143 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 71 G4143 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 7 h 39 m 39 sec
Reputation Power: 1
So what are you having problems with? Well besides C++.

Reply With Quote
  #3  
Old October 24th, 2012, 09:19 PM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,383 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 13 h 35 m 58 sec
Reputation Power: 383
"You'll get a little farther if you recognize that string constants in c have double quotes"
__________________
[code]Code tags[/code] are essential for python code!

Reply With Quote
  #4  
Old October 24th, 2012, 09:26 PM
notaprogrammer notaprogrammer is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 2 notaprogrammer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 58 sec
Reputation Power: 0
Quote:
Originally Posted by b49P23TIvg
"You'll get a little farther if you recognize that string constants in c have double quotes"


thanks, I changed that part already. At this point, I am guessing at the problems. Now re-reading my text book...again.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Newby needs help with simple program

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap