CSCI 1105 – Fall 2020 Assignment 03 – Due 29/10, 6 pm Please start this assignment early; programming and logic takes time - if you leave it to the last minute, you might not have enough time to finish or might make silly mistakes that you otherwise could avoid. Note that TAs and Instructors will not be able to answer last-minute questions! All work is to be handed in Mimir, our online code learning environment. We encourage you to write the code in IntelliJ (or any other IDE) and paste the solution in Mimir. To complete this assignment, you will need to know about: • Basic Input • Conditionals • Comparing different data types • Boolean Variables • Simple Input Validation • Loops Your code must compile. If it does not compile, you will receive a 0 (zero) on that portion of the assignment, and no partial marks will be given. Remember that students who hardcode their outputs to match the test cases in Mimir will receive a zero on the entire assignment. Grading Scheme: Please see the grading scheme at the end of this document. Variable names: We expect students to use descriptive variable names and methods names plus correct capitalization in the code they submit. This will be graded as it is important for code readability. As a reminder: variables names should start with lowercase (e.g., colour), and you must use camel case to combine two words (e.g.: currentSpeed). More examples of naming: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/variables.html Comments: We expect students to use comments in their code and include a header comment in all assignment files! This will be graded as it is important for code readability. The header comment should be placed first in the file and must conform to the following format: /* CSCI 1105 – Assignment X * First Last Names – B00xxxxxx * A brief description of the program */ Problem 1 – Managing Inventory (Warmup) The graphics card manufacturer Nvidia was recently criticized for the way they managed their inventory of the newly release RTX 3080 and 3090 graphics cards. To help Nvidia, you will create a program that keeps track of sales and restock of Nvidia's 3080 graphics cards. Your program will keep a record of the current inventory of the cards, and it will not allow new purchases when there are more than 50 cards (included) in backorder1 Your program will read integers representing either restock (adding new items to the inventory) or sales until it reads a 0 telling it to close the store and report. • Positive integers mean that new cards arrived in the stock (that is, an increase in the inventory) • Negative integers mean that the store sold cards that day • '0' means that the store is closed, and you should print how many cards are left in stock or how many are in backorder. Backorder Policy: If they have more than 50 cards (included) in backorder, the store will refuse to sell new cards until the inventory has been restocked to less than 50 cards in backorder. If a customer tries to purchase a card in this situation, your program should print an error message according to the example below. The store always open with a zero inventory of cards Examples: Input Output 10 10 -4 -4 0 Thank you! Store is now closed. Inventory: 12 9 -20 -30 -4 -10 -5 0 Im sorry, we cannot take new orders as our backorder list is >50 Thank you! Store is now closed. Inventory: -55 9 -20 -10 -4 -10 -5 0 Thank you! Store is now closed. Inventory: -40 1 A product in backorder means that the customer payed for it but did not receive the product yet since it was out of stock. Problem 2 – The Flu Shot As we approach winter, flu vaccinations become one of the priorities for public health officials. A vital public health metric is to know the percentage of the population vaccinated. In this problem, you will write a program that will keep track of the Atlantic Provinces (NS, NB, NFL, PEI). Your program will read vaccination reports numbers from each province (multiple reports are possible) and each province's total population. It will then print the % of the population vaccinated. It will also print a warning for any region that is below 80% vaccinated. The input is as follows: - You will read an integer and a word containing the numbers of newly vaccinated people and their province (e.g. 80 NS) o If the number is negative, you should ignore the input - You will read a 0 (zero) informing your program that there are no new vaccination reports - Then you will read an integer and province informing you of the total population of each province. - Please note that the names of the provinces will always be correct. Do not assume any order Your program will print the information according to the examples below. Please limit your decimal points to two digits using the printf method. You must also left pad your number with up to 3 zeros. Hint: the printf syntax for floats goes as follows: %width.decimalsf Hint2: You will have to print a %, which needs to be escaped. You do not escape % with \ Examples: Input Output 0 300 NS 300 NB 300 NFL 300 PEI 000.00% of NS's is vaccinated 000.00% of NB's is vaccinated 000.00% of NFL's is vaccinated 000.00% of PEI's is vaccinated Province(s) bellow vaccination quotas: NS NB NFL PEI 10 NS 280 NS 80 NFL 155 PEI -280 NS 30 NB 145 PEI 0 300 NS 300 NB 300 NFL 300 PEI 096.67% of NS's is vaccinated 010.00% of NB's is vaccinated 026.67% of NFL's is vaccinated 100.00% of PEI's is vaccinated Province(s) bellow vaccination quotas: NB NFL 290 NS 270 PEI 300 NFL 250 NB 0 300 PEI 300 NB 300 NS 300 NFL 096.67% of NS's is vaccinated 083.33% of NB's is vaccinated 100.00% of NFL's is vaccinated 090.00% of PEI's is vaccinated Province(s) bellow vaccination quotas: None Grading Scheme Each problem on the assignment will be graded based on three criteria: Functionality "Does it work according to specifications?" This is determined in an automated fashion by running your program on a number of inputs and ensuring that the outputs match the expected outputs. The score is determined based on the number of tests that your program passes. Quality of Solution "Is it a good solution?" This considers whether the solution is correct, efficient, covers boundary conditions, does not have any obvious bugs, etc. This is determined by visual inspection of the code. Initially full marks are given to each solution and marks are deducted based on faults found in the solution. Code Clarity "Is it well written?" This considers whether the solution is properly formatted, well- documented, and follows coding style guidelines. A single code clarity score is assigned for all solutions. If your program does not compile, it is considered non-functional and of extremely poor quality, meaning you will receive 0 for the solution. PROBLEM PARTIAL POINTS POINTS PROBLEM 1 30 Functionality 20 Quality of Solution & Code Clarity 10 PROBLEM 2 60 Functionality 50 Quality of Solution & Code Clarity 20 TOTAL 100 100
欢迎咨询51作业君