Hey guys I had an issue with some of the calculations they are not seeming to coming out correctly.
Program I was asked to write:
Problem Specification Hillside Rent-AllThe Hillside Rent-All Company requires a program that can generate an invoice for the rental of one ofits items (note that an item cannot be rented for a fraction of a day). The invoice should include thecurrent date, customer's name, item description, and all of the information that is required to computethe total cost and the balance due.The company uses the following equations to determine the costs:Rental Cost: Base Rental Cost + Cost Per Day x Number of DaysTax: 7% of the Rental CostTotal Cost: Rental Cost + TaxSecurity Deposit: 10% of the Total CostBalance Due: Total Cost - Security Deposit
Input data will be- the date that you enter the data- your name for the customer- Base Cost, Daily Cost, and Days
Code:
#include <iostream> // Required #include for running program#include <fstream>
#include <string>
#include <iomanip>
#include <fstream>
int main()
{
using namespace std;
const double SALES_TAX = .07; //constant values of sales tax
const double SECURITY_DEPOSIT = .10; // constant value of the security deposit required for renting equipment
string cust_name;
int month;
int day;
int year;
int days_rented;
double rental_cost;
double base_cost;
double total_cost;
double daily_cost;
double security_total;
double balance_due;
double item_tax;
//Inputs of the date / customer name / Number of rented days
cout << "Please Enter the month: ";
cin >> month;
cout << "Please Enter the day: ";
cin >> day;
cout << "Please Enter the year: ";
cin >> year;
cin.ignore(8, '\n');
cout << "Please enter your full name: ";
getline(cin, cust_name);
cout << "Please enter the number of days you wish to rent the item: ";
cin >> days_rented;
cout << "Please enter the Daily cost of the item you are renting:";
cin >> daily_cost;
cout << "Please enter the Base cost of the item:";
cin >> base_cost;
//Rental cost
rental_cost = base_cost + daily_cost * days_rented;
//total cost
total_cost = rental_cost * SALES_TAX;
//Security Deposit
security_total = total_cost * SECURITY_DEPOSIT;
// Tax amount
item_tax = SALES_TAX * total_cost;
//Balance left after security deposit
balance_due = total_cost - security_total;
cout << "Hillside Rent-All Company" << endl;
cout << "Date: " << month << "/" << day << "/" << year << endl;
cout << "Customer Name: " << cust_name << endl;
cout << "Item: Snow Blower" << endl;
cout << "Base Cost: " << base_cost << endl;
cout << "Daily Cost: " << daily_cost << endl;
cout << "Rental Cost: " << rental_cost << endl;
cout << "Tax Amount: " << item_tax << endl;
cout << "Total Cost: " << total_cost << endl;
cout << " Security Deposit: " << security_total << endl;
cout << "Balance Due: " << balance_due << endl;
return 0;
Output:
Please Enter the month: 5
Please Enter the day: 5
Please Enter the year: 5
Please enter your full name: Joe
Please enter the number of days you wish to rent the item: 5
Please enter the Daily cost of the item you are renting:5
Please enter the Base cost of the item:50
Hillside Rent-All Company
Date: 5/5/5
Customer Name: Joe
Item: Snow Blower
Base Cost: 50
Daily Cost: 5
Rental Cost: 75
Tax Amount: 0.3675
Total Cost: 5.25
Security Deposit: 0.525
Balance Due: 4.725
--------------------------------
Process exited after 11.14 seconds with return value 0
Press any key to continue . . .
Thank you in advanced this forum has been nothing but helpful to me.