Assignment #1:
A market store offers to their clients three different types of discount cards: bronze, silver and gold. Each card stores information about its owner, the turnover for the previous month and the initial discount rate. With each card you can calculate the discount of the current purchase. In general this is done using the formula: value_of_purchase * discount_rate.
The bronze card comes with no discount rate if the turnover for the previous month is below $100. If it is between $100 and $300, the discount rate is 1%. And if it is above $300, the rate is 2.5%.
The silver card comes with an initial discount rate of 2%. In case, the turnover is over $300, the rate is 3.5%.
The gold card comes with an initial discount rate of 2%. The discount rate grows 1% for each $100 from the turnover, capping at 10%.
Your task is:
Bronze:
a. Mock data: turnover $0, purchase value $150;
b. Output:
Purchase value: $150.00
Discount rate: 0.0%
Discount: $0.00
Total: $150.00
Silver:
a. Mock data: turnover $600, purchase value $850;
b. Output:
Purchase value: $850.00
Discount rate: 3.5%
Discount: $29.75
Total: $820.25
a. Mock data: turnover $1500, purchase value $1300;
b. Output:
Purchase value: $1300.00
Discount rate: 10.0%
Discount: $130.00
Total: $1170.00
You must provide the solution as a console application written in Java.
Modelling the store following the object-oriented principles
Create PayDesk class and its parts
Application Entry Point
Code Quality
1. Application source code
2. Explanation: a document that describes how the application is supposed to be started and how it works.
Assignment 2:
Three brothers walk into a bar. All the beverages are placed in one line at the long bar table. The size of each glass is represented in an array of integers, glasses.
The brothers will drink a round if they can find 3 consecutive glasses of the same size. The barman removes the empty glasses from the table immediately after each round.
Find the maximum number of rounds the three brothers can drink.
Example
For glasses = [1, 1, 2, 3, 3, 3, 2, 2, 1, 1], the output should be brothersInTheBar(glasses) = 3.
The brothers can start with a round of size 3, then after the glasses are cleared, a round of size 2 can be formed, followed by a round of size 1. One glass will be left at the table.
For glasses = [1, 1, 2, 1, 2, 2, 1, 1], the output should be brothersInTheBar(glasses) = 0.
There are no 3 consecutive glasses of the same size.
Input/Output
[input] array.integer glasses
The sizes of glasses in the row.
Guaranteed constraints:
1 ≤ glasses.length ≤ 105,
1 ≤ glasses[i] ≤ 106.
[output] integer
The example case passes
Happy path covered
Corner cases covered
Error handling
Optimization
Code formatting
Naming conventions
1. Application source code
2. Explanation: a text file that describes the algorithm logic.
Get Free Quote!
310 Experts Online