-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule2LABWeek1Option1.cpp
More file actions
80 lines (62 loc) · 2.86 KB
/
Copy pathModule2LABWeek1Option1.cpp
File metadata and controls
80 lines (62 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//************************************************************************
// Author: Rolando Carreon
// Date: feb 12 2025
// Language: C++
// Assignment: Module 2 Week 1 - Option 1
// Description: In this lab, I will create a program that calculates a
// homeowner's expenses, including the electric and rent.
// The program will provide the user with formatted output
// that they might use to create and water bills a printable
// report each month for their records.
//************************************************************************
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
// declare local variables //
// double used for decimal point values
// float not used becuase double is 64-bit while float is 32 //
double billRent;
double billElectric;
double billWater;
double billTotal;
// string used only for user month variable //
string userMonth;
// set precision sets shown decimal from 6 points to 2 points after,
// showpoint converts rent to a decimal and fixed displays default 0's //
cout << fixed << showpoint << setprecision(2);
// prompts user to enter the month //
cout << "Please enter the month: ";
cin >> userMonth;
// prompts user to enter the rent amount //
cout << "Please enter the Rent amount: ";
cin >> billRent;
// prompts user to enter the electric bill amount //
cout << "Please enter the Electric Bill amount: ";
cin >> billElectric;
// prompts user to enter the water bill amount and adds padding //
cout << "Please enter the Water Bill amount: ";
cin >> billWater;
cout << "\n\n";
// displays receipt of user interactions from prompts //
// sets width to 15, setfill and rent is justified left.
// justfied to the right is the $ symbol before the rent amount
// which is set to a new width of 7 to keep unfiorm //
cout << setw(15) << left << setfill(' ') << "Rent: "
<< right << "$ " << setw(7) << billRent << endl;
// same as rent but for electric amount //
cout << setw(15) << left << setfill(' ') << "Electric: "
<< right << "$ " << setw(7) << billElectric << endl;
// same as rent but for water amount //
cout << setw(15) << left << setfill(' ') << "Water: "
<< right << "$ " << setw(7) << billWater << endl;
// sets width to 25 on new line, justfied left and "-" setfill is used //
cout << setw(25) << left << setfill('-') << "" ;
// simple math function to calculate bill total before displaying //
billTotal = (billRent + billElectric + billWater);
// same as rent but for total, 2 addiational "\n" used //
cout << "\n" << setw(15) << left << setfill(' ') << "Total: "
<< right << "$ " << setw(7) << billTotal << "\n" << endl;
return 0;
}