-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssignment1.java
101 lines (84 loc) · 5.82 KB
/
Assignment1.java
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
Author: Sara Jane Kenny
Date: 15/11/2022
This program reads the weekly amount of general waste, recycling, organic waste, and glass generated by a household and will output the annual cost for each of the four companies.
*/
import java.util.Scanner;
import java.text.DecimalFormat;
public class demoSkills {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
DecimalFormat moneyFormat = new DecimalFormat ("0.00");
// Find out the amounts needed from the user
System.out.print("Enter the amount of general waste: ");
byte genWasteAmt = sc.nextByte ();
System.out.print("Enter the amount of recycling: ");
byte recyclingAmt = sc.nextByte ();
System.out.print("Enter the amount of organic waste: ");
byte orgWasteAmt = sc.nextByte ();
System.out.print("Enter the amount of glass: ");
byte glassAmt = sc.nextByte ();
sc.close();
// Setting the annual fees for each company
final float greenCleanFee = 180;
final float countryCollectFee = 170;
final float enviroFee = 150;
final float wasteAwayFee = 200;
// Calculating general waste amount annually for each company
float greenCleanAnnualGenWaste = (genWasteAmt * .21f) * 52;
float countryCollectAnnualGenWaste = (genWasteAmt * .14f) * 52;
float enviroAnnualGenWaste = (genWasteAmt * .30f) * 52;
float wasteAwayAnnualGenWaste = (genWasteAmt * .10f) * 52;
// Calculating recycling amount annually for each company
float greenCleanAnnualRecycling = 0;
float countryCollectAnnualRecycling = (recyclingAmt * 0.14f) * 52;
float enviroAnnualRecycling = 0;
float wasteAwayAnnualRecycling = (recyclingAmt * 0.10f) * 52;
// Calculating organic waste amount annually for each company
float greenCleanAnnualOrgcWaste = (orgWasteAmt * .10f) * 52;
float countryCollectAnnualOrgWaste = (orgWasteAmt * .10f) * 52;
float enviroAnnualOrgWaste = 0;
float wasteAwayAnnualOrgWaste = (orgWasteAmt * .10f) * 52;
// Calculating glass amount annually for each company
float greenCleanAnnualGlass = (glassAmt * .15f) * 52;
float countryCollectAnnualGlass = (glassAmt * .12f) * 52;
float enviroAnnualGlass = 0;
float wasteAwayAnnualGlass = (glassAmt * .10f) * 52;
// Calculating the total annually for each company for every waste recorded
float greenCleanTotalAnnum = greenCleanFee + greenCleanAnnualGenWaste + greenCleanAnnualRecycling + greenCleanAnnualOrgcWaste + greenCleanAnnualGlass;
float countryCollectTotalAnnum = countryCollectFee + countryCollectAnnualGenWaste + countryCollectAnnualRecycling + countryCollectAnnualOrgWaste + countryCollectAnnualGlass;
float enviroTotalAnnum = enviroFee + enviroAnnualGenWaste + enviroAnnualRecycling + enviroAnnualOrgWaste + enviroAnnualGlass;
float wasteAwayTotalAnnum = wasteAwayFee + wasteAwayAnnualGenWaste + wasteAwayAnnualRecycling + wasteAwayAnnualOrgWaste + wasteAwayAnnualGlass;
// A loop to make a long top line for the box
System.out.print("\u250F");
int topLine = 101;
for (int i = 0; i <= topLine; i++)
System.out.print("\u2501");
System.out.print("\u2513");
// Show-casing the user inputs in proper formatting
System.out.printf("\n\u2503%-20s%5skg%76s","General Waste:", genWasteAmt, "\u2503");
System.out.printf("\n\u2503%-20s%5skg%76s","Recycling Waste:", recyclingAmt, "\u2503");
System.out.printf("\n\u2503%-20s%5skg%76s","Organic Waste:", orgWasteAmt, "\u2503");
System.out.printf("\n\u2503%-20s%5skg%76s","Glass Waste:", glassAmt, "\u2503");
// Adding the title and formatting the box
System.out.printf("\n\u2503%103s", "\u2503");
System.out.print("\n\u2503");
System.out.printf("%35s%-60s%8s","", "Annual Waste Charges", "\u2503");
System.out.printf("\n\u2503%103s", "\u2503");
// Adding the category's and formatting the box
System.out.printf("\n\u2503%-18s%-14s%-14s%-14s%-14s%-12s%-11s%6s", "Company Name", "Annual", "General", "Recycling", "Organic", "Glass", "Total Cost","\u2503");
System.out.printf("\n\u2503%-18s%-14s%-14s%-14s%-14s%-12s%-11s%2s", "", "Service Fee", "Waste Cost", "Cost", "Waste Cost", "Cost", "Cost(per annum)","\u2503");
System.out.printf("\n\u2503%103s", "\u2503");
// Show-casing each company along with the finished calculations, as well as formatting the box
System.out.printf("\n\u2503%-18s€%-13s€%-13s€%-13s€%-13s€%-11s€%-11s%5s", "Green Clean", moneyFormat.format(greenCleanFee), moneyFormat.format(greenCleanAnnualGenWaste), moneyFormat.format(greenCleanAnnualRecycling), moneyFormat.format(greenCleanAnnualOrgcWaste), moneyFormat.format(greenCleanAnnualGlass), moneyFormat.format(greenCleanTotalAnnum), "\u2503");
System.out.printf("\n\u2503%-18s€%-13s€%-13s€%-13s€%-13s€%-11s€%-11s%5s", "Country Collect", moneyFormat.format(countryCollectFee), moneyFormat.format(countryCollectAnnualGenWaste), moneyFormat.format(countryCollectAnnualRecycling), moneyFormat.format(countryCollectAnnualOrgWaste), moneyFormat.format(countryCollectAnnualGlass), moneyFormat.format(countryCollectTotalAnnum), "\u2503");
System.out.printf("\n\u2503%-18s€%-13s€%-13s€%-13s€%-13s€%-11s€%-11s%5s", "Enviro", moneyFormat.format(enviroFee), moneyFormat.format(enviroAnnualGenWaste), moneyFormat.format(enviroAnnualRecycling), moneyFormat.format(enviroAnnualOrgWaste), moneyFormat.format(enviroAnnualGlass), moneyFormat.format(enviroTotalAnnum), "\u2503");
System.out.printf("\n\u2503%-18s€%-13s€%-13s€%-13s€%-13s€%-11s€%-11s%5s\n", "Waste Away", moneyFormat.format(wasteAwayFee), moneyFormat.format(wasteAwayAnnualGenWaste), moneyFormat.format(wasteAwayAnnualRecycling), moneyFormat.format(wasteAwayAnnualOrgWaste), moneyFormat.format(wasteAwayAnnualGlass), moneyFormat.format(wasteAwayTotalAnnum), "\u2503");
System.out.print("\u2517");
// A loop to make a long bottom line for the box
int bottomLine = 101;
for (int i = 0; i <= bottomLine; i++)
System.out.printf("\u2501");
System.out.print("\u251B");
}
}