Very new to coding so there might be a better way to phrase this. This issue you be obvious to most but I got to get better one step at a time. Any other advice to improve this code is very much welcomed.
Example:Welcome to Motown records Keth Kennedy, What will store will you be shopping with?
I Pass fff fff
The program will print all the cout below and pass all the other variables 0. so it will say you have spent 0 dollors.
#include <iostream> //Allows for input and output stream.
using namespace std; //Makes it so you don't have to add std::
int main() {
//All variables used in this binary.
string compname = "Motown Records";
const string Card = "Apple Card";
string Fname = "Keth";
string Lname = "Kennedy";
string expirationdate = "09/25";
double Maxbalance = 300.00f;
double cbalance = 250.00f;
double tamount;
double nbalance;
string storename;
string dot;
cout << "Welcome " << Fname <<" "<< Lname << " Employee of " << compname <<". What is the name of the store you will be buying from?" << endl; //Prints a welcome message with 3 vairables.
cin >> storename; //Uses user-input to define storename variables.
cout << "Thank you for shopping with " << storename << " Now, If you don't mind, How much will this transaction be?" << endl; //Prints a confirmation of storename and asks user to define tamount.
cin >> tamount; //Defines tamount with user input.
cout << "You will be spending " << tamount << ". What is the date of transaction?" << endl; //Prints a confirmation of how much user will be spending, then asks them to define the date of transaction.
cin >> dot; //Defines dot with user input.
cout << "Date of tranaction is " << dot << '.' << endl; //Prints a confirmation of the date of transaction.
if (tamount == 0) //Check to see if user passed tamount a string or 0.
{
cout << "You can not spend 0 dollors or you must enter a number, not letters." << endl; //Informs user they need a valid input.
}
else if((tamount > Maxbalance) || (tamount > cbalance)) //Checks if user passed tamount a variable greater then they can afford to spend.
{
cout << "You do not have enough for this transaction" << endl; //Informs user they can not afford this transaction.
}
else if ((tamount <= Maxbalance) && (tamount <= cbalance)) //Checks if user passed tamount a variable they can afford.
{
nbalance = cbalance - tamount; //Subtracts tamount from cbalance and passes its result into a new variable.
cout << "Transaction completed, you know have " << nbalance << " USD. Have a good day " << Fname << '.' << endl; //Informs user they can afford transaction and informs them of their new balance.
}
else //If something breaks, It should not, I tested it, but just in case it will output this.
{
cout << "Im sorry, I don't understand what you said. Please restart this application" << endl;
}
return 0;
}