NIT3112 Advanced Web Development P a g e 1 | 6 Coffee Victoria POS Lab Assessment 1 – Practical Programming Project Due date: Refer to Assignment Submission Box on VU Collaborate *** No late...

1 answer below »

View more »
Answered Same DayNov 01, 2021NIT3112

Answer To: NIT3112 Advanced Web Development P a g e 1 | 6 Coffee Victoria POS Lab Assessment 1 – Practical...

Arun Shankar answered on Nov 03 2021
163 Votes
main.cs
using System;
class Change
{
int[] notes;
int[] coins;
// NumberFormat formatter;
// Constructor
public Change(){
notes = new int[7]; // $1, $2, $5, $10,
$20, $50, and $100
coins = new int[5]; // 1c, 5c, 10c, 20c, 50c
}
// The function calculates and stores
// currency denominations
public void denChange(int amount)
{
// Make the notes[] array
if(amount >= 10000){
notes[0] = amount/10000;
amount = amount % 10000;
}
if(amount >= 5000){
notes[1] = amount/5000;
amount = amount % 5000;
}
if(amount >= 2000){
notes[2] = amount/2000;
amount = amount % 2000;
}
if(amount >= 1000){
notes[3] = amount/1000;
amount = amount % 1000;
}
if(amount >= 500){
notes[4] = amount/500;
amount = amount % 500;
}
if(amount >= 200){
notes[5] = amount/200;
amount = amount % 200;
}
if(amount >= 100){
notes[6] = amount/100;
amount = amount % 100;
}
// Make the coins array
if(amount >= 50){
coins[0] = amount / 50;
amount = amount % 50;
}
if(amount >= 20){
coins[1] = amount / 20;
amount = amount % 20;
}
if(amount >= 10){
coins[2] = amount / 10;
amount = amount % 10;
}
if(amount >= 5){
coins[3] = amount / 5;
amount = amount % 5;
}
if(amount >= 1){
coins[4] = amount;
}
}

public int[] getNotes(){
return notes;
}

public int[] getCoins(){
return coins;
}

public static String currency(int cents){
return "$" + (cents/100) + "." + (cents % 100);
}
} // end of class Change
class Product
{
String name;
int price;
int total;
// Constructor
public Product(String _name){
this.name...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here
March
January
February
March
April
May
June
July
August
September
October
November
December
2025
2025
2026
2027
SunMonTueWedThuFriSat
23
24
25
26
27
28
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
1
2
3
4
5
00:00
00:30
01:00
01:30
02:00
02:30
03:00
03:30
04:00
04:30
05:00
05:30
06:00
06:30
07:00
07:30
08:00
08:30
09:00
09:30
10:00
10:30
11:00
11:30
12:00
12:30
13:00
13:30
14:00
14:30
15:00
15:30
16:00
16:30
17:00
17:30
18:00
18:30
19:00
19:30
20:00
20:30
21:00
21:30
22:00
22:30
23:00
23:30