You friend, Cathy has a small business and knowing that you have taken a program
ID: 3645586 • Letter: Y
Question
You friend, Cathy has a small business and knowing that you have taken a programming class wants you to create an application for her. Her company is called Cathy's Candles. Cathy's Candles offers candles in three styles - tea lights, votives and pillars. The colors available are Federal Blue, Sunflower Yellow, Christmas Red and Milky White. The scented candles have an additional charge.We will make some assumptions - the credit card information of the customer is already in file, so only the name of the customer and their customer id will be obtained for this application. Only known customers are placing orders. At this point, Cathy's Candles cannot handle new customers since it is a small scale operation. Each order is processed only for one style, color, scented / unscented candles at this time. If the customer wants to place another order, a new run is needed.
Style Base Price Scented Price(Additional)
Tea Lights 5.75 1.00
Votives 8.75 2.00
Pillar 12.75 5.00
1. Prompt the user for the style of the candle. T or t for Tea lights, V or v for votives and P or p for Pillars are the acceptable choices. If the user enters any other character, they should be prompted until they enter the correct choice.
2. Prompt the user to enter Y or y for Yes, N or n for No. The question asked is "Do you want scented candles?" If the user enters any other character, they should be prompted until they enter the correct choice. Note: n is an acceptable character.
3. Next prompt the user for their color choice. The acceptable choices are F or f for Federal Blue, S or s for Sunflower Yellow, C or c for Christmas Red and M or m for Milky White. If the user enters any other character, they should be prompted until they enter the correct choice. Note: c is an acceptable character.
4. Make sure appropriate colors are printed in the summary. If the user enters Tea lights and no for scented candles, then price is calculated accordingly. Similarly if user enters Tea Lights and yes for scented candles, the price calculation is different because scented candles have an additional charge. Do this for all the different styles. if the user enter Y, then the summary should mention scented. If the user enter N, then the summary should mention unscented.
5. Prompt the user for the quantity of candles needed. Validation should be done so that quantity is not a negative number or 0.
6. Calculation:
a. Subtotal should be calculated first using a value returning function calcSubtotal. The price and quantity
are the formal parameters.
b. Shipping fee is calculated using a value returning function called calcShipping. The formal parameter is
subtotal. The shipping fee is 3% of the subtotal.
c. The tax is calculated using a value returning function called calcTax. The formal parameter is subtotal.
The tax is 8% of the subtotal.
d. The total due is a value returning function called calcTotal. The formal parameters are subtotal,
shipping fee and tax.
7. The summary should print scented or unscented candles, the style of candle, the color, the subtotal first, followed by the shipping fee, and sales tax and finally the total due. Print a message to show that the customers will be charged the amount using the credit card in file.
Here is my code so far: (Note I need to have functions to show user the info and to get customer information.
#include <iostream>
#include <string>
#include <iomanip>
#include <cctype>
using namespace std;
//constants declared for candle prices
const double tLight = 5.75;
const double votive = 8.75;
const double pillar = 12.75;
//function prototypes
void info();
void getCustomer(string& name, string& ID);
double calcSubtotal(double price, int numNeeded);
double calcShipping(double subtotal);
double calcTax(double subtotal);
double calcTotal(double subtotal, double shipFee, double tax);
int main()
{
string name, ID;
char style, scent, color, t, v, p;
double price, subTotal, shipFee, tax, total;
int numNeeded;
cout << fixed << showpoint << setprecision(2);//fixed decimal at 2
info();
getCustomer(name, ID);
cout << " Please enter the style of candle that you want: ";
cout << "T or t for Tea Light, V or v for Votive, or P or p for Pillar: ";
cin >> style;
//from here I need to convert the lowercase letters to uppercase then test them
//to make sure they are T, V, or P. If not, needs to loop to question again.
cout << " Do you want scented candles? Please enter Y or y for yes and N ";
cout << "or n for No: ";
cin >> scent;
//need loop here, but don't know how to make it not print result
cout << " What is your color choice? ";
cout << "Enter F or f for Federal Blue, S or s for Sunflower Yellow, C or ";
cout << "c for Christmas Red, and M or m for Milky White: ";
cin >> color;
//need loop here, but don't know how to make it not print result
cout << " Enter the quantity needed: ";
cin >> numNeeded;
//cout << "Your subtotal for the" << scent << "candles" << style << "in"
//<< color << "is: $" << calcSubtotal(subTotal);
//cout << " Your shipping fee is: $" << calcShipping(shipFee);
//cout << " The sales tax is: $" << calcTax(tax);
//cout << The total due is: $" << calcTotal(total);
cout << " Your credit card in our files will be charged $"; //<<calcTotal(total);
cout << " Thank you for shopping with us today! ";
cout << "Have a nice day! ";
system ("pause");
return 0;
}
void info()
{
cout << " ****** Welcome to Cathy's Candles! ***** ";
cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ";
cout << "We offer tea light, votives, and pillar candles in the following colors: "
<< "Federal Blue, Sunflower Yellow, Christmas Red, and Milky White. "
<< "There is an additional fee for scented candles. Please follow the "
<< "instructions and enter the number of candles needed. ";
cout << "Style " "Base Price " "Scented Price(additional) ";
cout << "Tea Light " "$5.75 " "$1.00 ";
cout << "Votive " "$8.75 " "$2.00 ";
cout << "Pillar " "$12.75 " "$5.00 ";
}
void getCustomer(string& name, string& ID)
{
cout << "Please enter your full name and press enter: ";
getline (cin, name);
cout << "Please enter your customer ID and press enter: ";
getline (cin, ID);
}
double calcSubtotal(double price, int numNeeded)
{
double subTotal;
subTotal = price * numNeeded;
return subTotal;
}
double calcShipping(double subtotal)
{
double shipFee;
shipFee = subtotal * .03;
return shipFee;
}
double calcTax(double subtotal)
{
double tax;
tax = subtotal * .08;
return tax;
}
double calcTotal(double subtotal, double shipFee, double tax)
{
double total;
total = subtotal + shipFee + tax;
return total;
}
Explanation / Answer
#include <cstdlib>
#include <string>
#include<iostream>
#include<math.h>
using namespace::std;
int main(){
char x;
cout<<"enter the color,F or f for Federal Blue, S or s for Sunflower Yellow, C or c for Christmas Red and M or m for Milky White"<<endl;
cin>>x;
for(int i=1; i<=4;){ /*initiating infinite loop */
if(x=='F'|x=='f'|x=='S'|x=='s'|x=='C'|x=='c'|x=='M'|x=='m'){
break;}
else{
cout<<"invalid choice enter again"<<endl;cin>>x;}
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.