How to include dollar signs? - c++

For a project I have to write an application that calculates the price of gas. The code works great, but I noticed something that will probably get points deducted. My total price doesn't include a dollar sign. I am stuck on where to add them and how. Below is my code. Please help!
// FinalProject1.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
using namespace std;
const double PRICE_OF_REGULAR = 1.67;
const double PRICE_OF_SPECIAL = 1.87;
const double PRICE_OF_SUPER = 1.99;
int main()
{
cout << "Gas Pump Calculator!" << endl;
double numberOfGallons;
cout << "Please enter number of gallons needed: ";
cin >> numberOfGallons;
cout << endl;
cout << "1. Regular" << endl;
cout << "2. Special" << endl;
cout << "3. Super+" << endl;
cout << endl;
int choice;
cin >> choice;
switch (choice)
{
case 1:
cout << endl;
cout << "You chose regular. The total price of gas is: " << (numberOfGallons * PRICE_OF_REGULAR);
cout << endl;
break;
case 2:
cout << endl;
cout << "You chose special. The total price of gas is: " << (numberOfGallons * PRICE_OF_SPECIAL);
cout << endl;
break;
case 3:
cout << endl;
cout << "You chose super+. The total price of gas is: " << (numberOfGallons * PRICE_OF_SUPER);
cout << endl;
break;
}
return 0;
}

Just print a dollar sign after the number:
cout << "You chose regular. The total price of gas is: "
<< (numberOfGallons * PRICE_OF_REGULAR) << "$";
//^ add dollar sign
Or before the number, depending on how you want to print it out.
cout << "You chose regular. The total price of gas is: $"
<< (numberOfGallons * PRICE_OF_REGULAR); //^ add dollar sign

Just add it before your value:
cout << "You chose regular. The total price of gas is: $"
<< (numberOfGallons * PRICE_OF_REGULAR);

Related

Cin not producing required results

i'm trying to set up a simple flight booking system program, but my second bit of cin code is not calling for input when i run the program. Unlike the initial cin that requires your name initially. the program just runs and returns 0. I'm a beginner at c++ and i know this is a simple fix so please be understanding . Thank you any guidance will be greatly appreciated.
#include <iostream>
#include <sstream>
using namespace std;
int main()
{
int name;
int Seatnumber;
int optionnumber = 1-5 ;
std::string out_string;
std::stringstream ss;
ss << optionnumber;
out_string = ss.str();
cout << "Welcome to the COS1511 Flight Booking System" "\n" << endl;
cout << "Enter full name : " << endl;
cin >> name ; "\n";
cout << "\n" "The Available travel times for flights are:" << endl;
cout << " Depart Arrive" << endl;
cout << "1. 7.00 9.30" << endl;
cout << "2. 9.00 11.30" << endl;
cout << "3. 11.00 13.30" << endl;
cout << "4. 13.00 15.30" << endl;
cout << "5. 15.00 17.30" << endl;
cout << "Choose the time by entering the option number from the displayed list : " << endl;
cin >> optionnumber ;
if (optionnumber == 1-5){
cout << "\n" "The available seats for are as follows " << endl;
}
else
cout << "Incorrect option! Please Choose from 1-5 " << endl;
cout << "First Class(1920)" << endl;
cout << "|A1||A2||A3|----|A4||A5||A6|" << endl;
cout << "|B1||B2||B3|----|B4||B5||B6|" << endl;
cout << "|C1||C2||C3|----|C4||C5||C6|" << endl;
cout << "|D1||D2||D3|----|D4||D5||D6|" << endl;
cout << "| Economy Class(1600)" << endl;
cout << "|E1||E2||E3|----|E4||E5||E6|" << endl;
cout << "|F1||F2||F3|----|F4||F5||F6|" << endl;
cout << "|G1||G2||G3|----|G4||G5||G6|" << endl;
cout << "|H1||H2||H3|----|H4||H5||H6|" << endl;
cout << "|I1||I2|" << endl;
cout << "Please Key in a seat number to choose a seat(eg: A2)" << endl;
cin >> Seatnumber;
}
prompt the user to enter their name.
Then display a menu showing the available times for the flight.
the user can choose a preferred departure time(option 1-5)
the option selected should be validated for 1-5
if the user entered the correct time a seating arrangement for that particular flight time should be displayed to the next user for the user to choose a seat.
Warning
int optionnumber = 1-5 ;
does
int optionnumber = -4 ;
and
if (optionnumber == 1-5){
does
if (optionnumber == -4){
but you wanted if ((optionnumber >= 1) && (optionnumber <= 5))
if the user entered the correct time a seating arrangement for that particular flight time should be displayed to the next user for the user to choose a seat.
No, whatever the result of the test above you continue and write "First Class(1920)" etc so even when the choice is invalid
in
cin >> name ; "\n";
what did you expect about the "\n" ?
I encourage you to check the read success, currently if the user does not enter an integer you do not know that
But are you sure the name must be an integer ? Probably it must be s string
out_string is unused, it can be removed
Visibly Seatnumber is not an int but a string (A1 ...)
you probably want to loop until a valid time is enter, also fixing the other problems a solution can be :
#include <iostream>
#include <string>
using namespace std;
int main()
{
string name;
string Seatnumber;
int optionnumber;
cout << "Welcome to the COS1511 Flight Booking System" "\n" << endl;
cout << "Enter full name : " << endl;
if (!(cin >> name))
// EOF (input from a file)
return -1;
cout << "\n" "The Available travel times for flights are:" << endl;
cout << " Depart Arrive" << endl;
cout << "1. 7.00 9.30" << endl;
cout << "2. 9.00 11.30" << endl;
cout << "3. 11.00 13.30" << endl;
cout << "4. 13.00 15.30" << endl;
cout << "5. 15.00 17.30" << endl;
cout << "Choose the time by entering the option number from the displayed list : " << endl;
for (;;) {
if (!(cin >> optionnumber)) {
// not an int
cin.clear(); // clear error
string s;
// flush invalid input
if (!(cin >> s))
// EOF (input from a file)
return -1;
}
else if ((optionnumber >= 1) && (optionnumber <= 5))
// valid choice
break;
cout << "Incorrect option! Please Choose from 1-5 " << endl;
}
cout << "\n" "The available seats for are as follows " << endl;
cout << "First Class(1920)" << endl;
cout << "|A1||A2||A3|----|A4||A5||A6|" << endl;
cout << "|B1||B2||B3|----|B4||B5||B6|" << endl;
cout << "|C1||C2||C3|----|C4||C5||C6|" << endl;
cout << "|D1||D2||D3|----|D4||D5||D6|" << endl;
cout << "| Economy Class(1600)" << endl;
cout << "|E1||E2||E3|----|E4||E5||E6|" << endl;
cout << "|F1||F2||F3|----|F4||F5||F6|" << endl;
cout << "|G1||G2||G3|----|G4||G5||G6|" << endl;
cout << "|H1||H2||H3|----|H4||H5||H6|" << endl;
cout << "|I1||I2|" << endl;
cout << "Please Key in a seat number to choose a seat(eg: A2)" << endl;
cin >> Seatnumber;
return 0;
}
Compilation and execution :
pi#raspberrypi:/tmp $ g++ -pedantic -Wextra -Wall cc.cc
pi#raspberrypi:/tmp $ ./a.out
Welcome to the COS1511 Flight Booking System
Enter full name :
bruno
The Available travel times for flights are:
Depart Arrive
1. 7.00 9.30
2. 9.00 11.30
3. 11.00 13.30
4. 13.00 15.30
5. 15.00 17.30
Choose the time by entering the option number from the displayed list :
aze
Incorrect option! Please Choose from 1-5
7
Incorrect option! Please Choose from 1-5
2
The available seats for are as follows
First Class(1920)
|A1||A2||A3|----|A4||A5||A6|
|B1||B2||B3|----|B4||B5||B6|
|C1||C2||C3|----|C4||C5||C6|
|D1||D2||D3|----|D4||D5||D6|
| Economy Class(1600)
|E1||E2||E3|----|E4||E5||E6|
|F1||F2||F3|----|F4||F5||F6|
|G1||G2||G3|----|G4||G5||G6|
|H1||H2||H3|----|H4||H5||H6|
|I1||I2|
Please Key in a seat number to choose a seat(eg: A2)
qsd
pi#raspberrypi:/tmp $
Note entering the name with cin >> name does not allow it to contain several names separated by a space, to allow composed name getline can be used

Cases and Switch Issue

I am writing a program that simulates an ATM. So it tracks account balances, withdrawals and deposits in a very basic matter.
Everything works well during the first iteration, but if I go to make two or more deposits or withdrawals, the account balances default back to the original amount.
Here is an example of what is currently happening: I have $1,000 in my account initially. I make a deposit of $50. It prints out that I now have $1,050 in my account and asks if I would like to perform any other actions. (This is all good). If I select that I want to make another deposit of $100, it says my new account balance is $1,100 instead of $1,150. It does not store my latest account balance when I perform new withdrawals or deposits.
The second (less important) issue is that each time a withdrawal is made, there is a $2.50 fee for each withdrawal that also gets subtracted from my account balance.
I have not learned loops yet, only Cases, If statements and If Else Statements.
Is it possible to do what I want to do? Below is my code. Thank you in advance! This is my first time posting, so if I have pasted my code wrong, I apologize.
#include <iostream>
#include <string>
using namespace std; // opens library for "cout"
int main()
{
float test;
int logout;
string name;
float balance;
float fee;
int choice;
float withdraw;
float deposit;
float bonus;
bonus = 2.50;
balance = 1572.36;
fee = 12.50;
char answer;
cout << "Hello, thank you for banking with Pallet Town Bank.\n";
cout << "Please enter your name. ";
cin >> name;
cout << "Hello " << name << ". Your current balance is $" << balance << ".\n";
cout << "There will be a a service fee of $12.50 subtracted from your "
"account.\n";
cout << "Your updated balance will be $" << balance - fee << " \n";
cout << "What would you like to do today?\n";
do
{
cout << "\n1 - Current Balance\n2 - Withdraw\n3 - deposit\n4 - Log "
"Out\nOption: ";
cin >> choice;
switch (choice)
{
case 1:
cout << "\nCurrent Balance is " << balance - fee - withdraw + deposit
<< " \n";
cout << "Would you like to take any other actions today?\n";
break;
case 2:
cout << "\nWithdraw - How much would you like to withdraw? $";
cin >> withdraw;
cout << "Your new balance after withdrawing $" << withdraw << " will be $"
<< balance - fee - withdraw + deposit << "\n";
cout << "Would you like to take any other actions today?\n";
break;
case 3:
cout << "\nDeposit - How much would you like to deposit? $";
cin >> deposit;
test = balance - fee - withdraw + deposit;
cout << "Your new balance after depositing $" << deposit << " will be $"
<< test << endl; //<<balance - fee - withdraw + deposit<<"\n";
cout << "Would you like to take any other actions today? Y or N \n";
cin >> answer;
cout << answer;
if (answer == 'y' || 'Y')
{
test = balance - fee - withdraw + deposit + deposit;
cout << "Your new balance after depositing $" << deposit << " will be $"
<< test << endl;
}
// cout <<"Your new balance after depositing $"<<deposit<<" will be $"
// <<test<< endl; //<<balance - fee - withdraw + deposit<<"\n";
// cout <<"Would you like to take any other actions today?\n";
break;
case 4:
cout << "\nLog Out - Thank you for banking with Pallet Town Bank. Have "
"a great day!";
}
} while (choice != 4);
}
The main issue, as Alan Birtles points out, is that you never update the balance value; you just store the temporary calculations in the test variable.
Here's how you could change your code. I tried interpreting the expected behaviour of the program as best I could from the text:
#include <iostream>
#include <string>
using namespace std;
int main()
{
const double fee = 12.50;
double balance = 1572.36;
cout << "Hello, thank you for banking with Pallet Town Bank.\n";
cout << "Please enter your name. ";
string name;
cin >> name;
cout << "Hello " << name << ". Your current balance is $" << balance << ".\n";
cout << "There will be a a service fee of $12.50 subtracted from your "
"account.\n";
cout << "Your updated balance will be $" << (balance -= fee) << " \n";
cout << "What would you like to do today?\n\n";
while (true)
{
cout << "1 - Current Balance" << '\n'
<< "2 - Withdraw" << '\n'
<< "3 - deposit" << '\n'
<< "4 - Log Out" << '\n'
<< "Option: ";
int choice;
cin >> choice;
cout << endl;
if (choice == 4) break;
switch (choice)
{
case 1:
cout << "Current Balance is " << balance << '\n';
break;
case 2:
cout << "Withdraw - How much would you like to withdraw? $";
double withdraw;
cin >> withdraw;
cout << "Your new balance after withdrawing $" << withdraw << " will be $"
<< (balance -= withdraw) << '\n';
break;
case 3:
cout << "Deposit - How much would you like to deposit? $";
double deposit;
cin >> deposit;
cout << "Your new balance after depositing $" << deposit << " will be $"
<< (balance += deposit) << '\n';
break;
}
cout << "Would you like to take any other actions today? ";
char answer;
cin >> answer;
cout << endl;
if (toupper(answer) == 'N') break;
}
cout << "Log Out - Thank you for banking with Pallet Town Bank. Have a great day!" << endl;
}
Live demo
Changes
First of all, every time a modification is made (withdrawal/deposit), we need to actually update the balance. We can do so by using the += or -= operators (called "compound assignment" operators): when writing balance += x, we're adding x to balance, and when writing balance -= x we're subtracting. These expressions are equivalent to balance = balance + x and balance = balance - x, respectively.
I moved the "Would you like to [...]" part outside the switch statement, to avoid repeating it in each case.
As pointed out in the comments, answer == 'Y' || 'y' isn't the same as answer == 'Y' || answer == 'y'. I changed that to toupper(answer) == 'Y'.
I moved the logout handling outside the while loop, so that whenever the loop terminates, the logout message is always shown. That allows us to remove case 4 from the switch statement, by checking at the beginning if choice == 4 and then breaking out of the loop accordingly. This also implies the loop becomes a while (true) loop. Probably there is a more elegant way.
Even better
If you're confortable with functions, I would suggest refactoring the code, isolating each operation individually:
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;
const int FEE = 1250; // fee in cents
//---- Utilities ----//
string moneyString(int cents) {
ostringstream oss;
oss << cents/100 << '.' << cents % 100;
return oss.str();
}
int toCents(double money) {
return int(round(money*100));
}
int getMoney() {
double money;
cin >> money;
return toCents(money);
}
//---- User input ----//
// Available choices
enum Choices {
BALANCE = 1,
WITHDRAW = 2,
DEPOSIT = 3,
LOGOUT = 4
};
short int getChoice() {
short int choice = 0;
while (choice < 1 or choice > 4) {
cout << "1 - Current Balance" << '\n'
<< "2 - Withdraw" << '\n'
<< "3 - deposit" << '\n'
<< "4 - Log Out" << '\n'
<< "Option: ";
string input;
cin >> input;
choice = atoi(input.c_str());
cout << endl;
}
return choice;
}
bool userWantsMoreActions() {
cout << "Would you like to take any other actions today? ";
char answer;
cin >> answer;
cout << endl;
return toupper(answer) == 'Y';
}
//---- Actions ----//
void greeting(double &balance) {
cout << "Hello, thank you for banking with Pallet Town Bank.\n";
cout << "Please enter your name. ";
string name;
cin >> name;
cout << "Hello " << name << ". Your current balance is $" << moneyString(balance) << ".\n";
cout << "There will be a a service fee of $12.50 subtracted from your account.\n";
cout << "Your updated balance will be $" << moneyString(balance -= FEE) << " \n";
cout << "What would you like to do today?\n\n";
}
void printBalance(const double &balance) {
cout << "Current Balance is " << balance << '\n';
}
void withdraw(double &balance) {
cout << "Withdraw - How much would you like to withdraw? $";
int withdraw = getMoney();
cout << "Your new balance after withdrawing $" << withdraw << " will be $"
<< (balance -= withdraw -= FEE) << '\n';
}
void deposit(double &balance) {
cout << "Deposit - How much would you like to deposit? $";
int deposit = getMoney();
cout << "Your new balance after depositing $" << moneyString(deposit)
<< " will be $" << moneyString(balance += deposit -= FEE) << '\n';
}
int main()
{
// Initialize a sample session:
double balance = 157236;
greeting(balance);
while (true)
{
short int choice = getChoice();
if (choice == Choices::BALANCE) printBalance(balance);
else if (choice == Choices::WITHDRAW) withdraw(balance);
else if (choice == Choices::DEPOSIT) deposit(balance);
else if (choice == Choices::LOGOUT) break;
if (not userWantsMoreActions()) break;
}
cout << "Log Out - Thank you for banking with Pallet Town Bank. Have a great day!" << endl;
}
Live demo

Car Loan Calculation (C++)

My objective is to calculate and output a loan repayment schedule. The thing I would like to get help on is putting the principles added to the equation and printing out the repayment schedule. I am not sure if I did the calculations right as I have not had a personal finance class yet, and still get to grasp the concept of loans.
The loan repayment schedule is based on full price of an auto, their interest rate and their payment, assuming no money is put down. All fees and taxes are included in the price and will be financed. I also have to out put the repayment schedule to both the screen and a file - one month per line. . If the user has a credit rate of 800, they get a 3% annual interest rate; 700+ gets 5% interest rate; 600+ get 7% interest rate; and less than 600 get 12% interest rate
The credit scores for 700, 600, and below 600 are left blank because I am just going to copy the 800 credit score part again but change the interest rates.
// This program calculates a loan depending on the pereson's credit score
// how much they can pay per month. It almost outputs the month, principal,
// payment, interest, and the money that's been applied
#include <iostream>
#include <cstdio>
#include <iomanip>
using namespace std;
int main() {
int month = 0, creditScore = 0, whichCar;
double principle, payment = 0.0, interestPaid, applied, interestRate;
cout << fixed << setprecision(2) << showpoint; // Sets total or whatever to 2 decimal points
cout << "---------------------------------------------" << endl; // Displays welcome banner
cout << "| |" << endl;
cout << "| JOLLY GOOD SHOW WE HAVE CARS AYEEE |" << endl;
cout << "| |" << endl;
cout << "---------------------------------------------" << endl;
cout << endl;
cout << "Hey, I see you want a car. You can only purchase one car though." << endl;
cout << endl;
cout << "1. Furawree: $6,969.69" << endl; // Displays menu of autos
cout << "2. Buggee: $420,420.420" << endl;
cout << "3. Sedon: $900" << endl;
cout << "4. Truck: $900,000.90" << endl;
cout << "5. Couppee: $22,222.22" << endl;
cout << endl;
cout << "Which car would you like to purchase?" << endl; // Asks user car type and user inputs car #
cout << "Please enter the number of the car: ";
cin >> whichCar;
cout << endl;
switch(whichCar) { // If user choses a number 1-5, then it asks them how much they can pay each month for the car and their credit score
case 1: // FURAWREE
principle = 6969.69;
break;
case 2: // BUGGEE
principle = 420420.42;
break;
case 3: // SEDON
principle = 900;
break;
case 4: // TRUCK
principle = 900000.90;
break;
case 5: // COUPPEE
principle = 22222.22;
break;
default: // If user doesn't pick a number from 1-5
cout << "Yea uhhmmm we don't have that sorry, go away." << endl;
}
cout << "Please enter how much you can pay each month for this Furawree: ";
cin >> payment;
cout << "Please enter your credit score: ";
cin >> creditScore;
if (creditScore >= 800) {
interestRate = .03 / 12;
do {
interestPaid = principle * interestRate;
applied = payment - interestPaid;
month++;
} while (principle < 0) ;
cout << "Month " << " Principle " << " Payment " << " Interest " << " Applied " << endl;
cout << month << " $" << principle << " $" << payment << " " << interestPaid << " $" << applied << endl;
} else if (creditScore >= 700) {
// Will be copied from the 800 credit score
} else if (creditScore >= 600) {
// Will be copied from the 800 credit score
} else {
// Will be copied from the 800 credit score
}
cout << endl;
cout << endl;
cout << "Your payment: $" << payment << endl;
cout << "Your credit score: " << creditScore << endl;
cout << endl;
cout << endl;
system("pause");
return 0;
}
Mate, you need to fix code under credit - 800.
loop condition is incorrect
cout is after the loop, therefore it will print only once .
principle is not incremented nor decremented . and you are checking if principle is less than 0, however principle is set more than 0. so the loop will execute only once.
you need a fix some thing like this. I have just fine tuned little bit. pls fix the rest
if (creditScore >= 800) {
interestRate = .03 / 12;
cout << "Month " << " Principle " << " Payment " << " Interest " << " Applied " << endl;
cout <<"-------------------------------------------------------" << endl;
do {
interestPaid = principle * interestRate;
applied = payment - interestPaid;
principle = principle - applied;
cout << month << " $" << principle << " $" << payment << " " << interestPaid << " $" << applied << endl;
month++;
} while (principle > 0) ;
} else if (creditScore >= 700) {
Note :-
The above code is not following any object oriented concepts. Its not even functional programming. Introduce classes, methods to reduce headache and it will help to debug.
use \t\t to get spaces instead of spaces.
This code will need a big re-work to make it look professional .

C++ char not being written?

I'm working on a banking program, but I've come across a weird problem with
cin>> task;
It's supposed start up a switch. but it keeps skipping the input and ends the program.
I even have an example of this on hand, that code works, but this one doesn't I'm not sure what I'm doing wrong.
#include<iostream>
#include<conio.h>
#include<string>
#include <ctype.h>
using namespace std;
int main()
{
string name = "";
int count;
char task;
double bal = 0;
int depo, withd;
cout << "Welcome to bank of the future! Please sign in" << endl;
cin >> name;
cout << "Enter your account number." << endl;
cin >> count;
cout << "Welcome back " << name << " What would you like to do?";
cout << "\n A. Deposit \n B. Withdraw \n C. Show balance \n D. Quit" << endl;
cin >> task;
//just to check if it's being skipped over or not.
cout << "egg " << endl;
switch (task)
{
case 'A':
cout << "Enter an amount to deposit" << endl;
cin >> depo;
cout << "Prevous balance: " << bal << endl;
bal = bal + depo;
cout << "New balance: " << bal << endl;
break;
case 'B':
cout << "Enter an amount to withdraw" << endl;
cin >> withd;
cout << "Prevous balance: " << bal << endl;
bal = bal - withd;
cout << "New balance: " << bal << endl;
break;
case 'C':
cout << "Your current balance is " << bal << "\n For account: " << name << "Acount number: " << count << endl;
break;
case 'D':
cout << "Goodbye forever" << endl;
break;
}
return 0;
}
I think it may have to do with the char being upper or lower case. In the switch you specify that task is uppercase. When I tried your code with uppercase letters it worked for me, but when I entered a lowercase letter it ended the program.

C++ While Loops

I am having trouble getting my while loop to run. I am a very beginner coder and I have made many attempts with no success to make this work. I need help PLEASE!! Please be very specific and with laymen terms with your help since I am new to this.
#include <iostream>
#include <string>
using namespace std;
int main()
{
string mystr1;
string mystr2;
cout << "Please provide your first and last name" << endl;
getline (cin, mystr1);
cout << endl;
cout << "Please provide your shipping address" << endl;
getline (cin, mystr2);
cout << endl;
cout << "Hello " << mystr1 << " and welcome to Faulk Couture
Handbags Boutique" << endl; // prints Hello and welcome to Faulk
Couture Handbags Boutique
cout << endl;
cout << "We have a variety of specialty and fashionable handbags to
select from. Please see below for the available products and their
descriptions." << endl;
cout << endl;
cout << "Product 1: Crosby Carryall in black priced at $395. This
sophisticated and spacious Crosby Carryall is a work-to-weekend favorite
and is finished with " << endl;
cout << "bound leather edges, a detachable leather strap and petite
brass turnlocks securing its two zippered compartments."<< endl;
cout << endl;
cout << "Product 2: Prairie satchel with chain nude priced at $450.
Crafted in lightweight pebble leather with a bit of sheen, this
gracefully curved shape distills" <<endl;
cout << "the satchel to its purest form. The simple design is finished
with a slender strap and an elegant chain detail that detaches for a
different look." << endl;
cout << endl;
cout << "Product 3: Faulk Swagger 20 brown priced at $325. This
Statement belting with double-turnlock hardware is one of our most
popular designs with a little bit of “swagger.” "<< endl;
cout << "Named for a bold, brass-trimmed Bonnie Cashin design from 1967,
this very modern carryall in refined pebble leather comes finished with
a detachable strap for crossbody wear." << endl;
cout << endl;
cout << "Product 4: Zip top tote in brown priced at $285. This
sophisticated and light weight in signature canvas with hand-finished
leather trim, this aptly named tote is made for one-the-go ease." <<
endl;
cout << "A modern, flared shape and oversized strap anchors add playful
proportions to its spacious, brightly lined design." << endl;
cout << endl;
cout << "Product 5: Wristlet 24 priced at $175. This striking, feminine
design in polished pebble leather has space enough for a tablet and an
elegant chain that converts it from wristlet to top handle." << endl;
cout << "A dog-leash clip on the strap and an embossed hangtag charm
finish it with signature Faulk Couture Style." << endl;
cout << endl;
double cost, total, amount;
int product;
cout << "Please enter the product number for your bag choice" << endl;
cin >> product;
cout <<"The respective price for this bag is: " << endl;
cin>>cost;
cout<<"Please enter the quantity you would like to purchase for this
bag choice" << endl;
cin>>amount;
total = cost*amount;
cout <<"Your total purchase price for " <<amount<< " qty of product
number " <<product<< " is " <<total<<"."<< endl;
int choice=1;
while (choice==1);
{
cout << "To purchase another bag, please enter 1 (anything else to
quit)" << endl;
cin >> choice;
cout << "Please enter the product number for your next bag choice" <<
endl;
cin >> product;
cout << "The respective price for this bag is: " << endl;
cin >> cost;
cout << "Please enter the quantity you would like to purchase for this
bag choice" << endl;
cin >> amount;
total = cost*amount;
cout <<"Your total purchase price for " <<amount<< " qty of product
number " <<product<< " is " <<total<<"."<< endl;
}
cout << endl;
return 0;
}
You're ending your while loop with a semicolon that's why it isn't entering the while loop
Here is the while loop without the semicolon
while (choice==1) {
cout << "To purchase another bag, please enter 1 (anything else to
quit)" << endl;
cin >> choice;
cout << "Please enter the product number for your next bag choice" <<
endl;
cin >> product;
cout << "The respective price for this bag is: " << endl;
cin >> cost;
cout << "Please enter the quantity you would like to purchase for this
bag choice" << endl;
cin >> amount;
total = cost*amount;
cout <<"Your total purchase price for " <<amount<< " qty of product
number " <<product<< " is " <<total<<"."<< endl;
}