CS 163/164, Fall 2018
Programming Assignment - P2
Strange Formulas
Due Tuesday, Sep. 4th at 6:00pm
Late - Wednesday, Sep. 5th at 8:00am
Objectives of this Assignment
- To write a Java program to implement formulas,
- to learn how to read input from the user via the console,
- to declare variables and use them in expressions, and
- to learn about printing formatted output to the console.
- to learn that you can implement a formula that you are not familiar with.
Instructions
Write a Java program file called P2.java with a class name P2, an example of
the code is shown below. All of the Java code you write should be contained
in the main method. For this assignment, you must follow the directions below
exactly:
Program Structure
// P2 Assignment Solution
// Author: Ms. White
// Date: 8/27/2018
// Class: CS163/164
// Email: white@colostate.edu
import java.util.Scanner;
public class P2 {
public static void main(String[] args) {
// Declare variables for mysterious formulas
// Instantiate scanner
Scanner keyboard = new Scanner(System.in);
// Prompt and read alphaAcid from keyboard
// Prompt and read ounces from keyboard
// Calculate HBUs
// Print HBUs to console
// Prompt and read remaining variables
// Compute the SRM value using the formula
// Print SRM to console
// Close scanner
keyboard.close();
}
}
Sample Output
Your program should print 7 lines, as below. The user input is shown in blue.
Alpha Acid? 5.0
Ounces? 2.0
The HBUs are 10.00.
Weight? 1.0
Lovibond? 80.0
Volume? 5.0
The SRM value is 9.5000.
Specifications
- Work on your own, as always.
- The name of the source code file must be exactly
P2.java
- Name the file exactly - upper and lower case matters!
- Comments at the top as shown above.
- Assignments should be implemented using Eclipse.
- Assignments should be implemented using Java, version 1.8.
- Make sure your code runs on machines in the CSB 120 lab.
- Turn in through the Checkin tab.
- Read the syllabus for the late policy.
- We will be checking programs for plagiarism, so please don't copy from anyone else.
Grading Criteria
- 100 points for perfect submission.
- 0 points for no submission, will not compile, submitted class file, etc.
- Preliminary Tests
Preliminary tests use the values above for all inputs.
- testCompile: checks that program compiles. (0 points)
- test1: checks first line of output with the prompt and Alpha Acid % entered by user. (10 points)
- test2: checks second line of output with the prompt and Ounces entered by user. (10 points)
- test3: checks third line of output with the HBUs. (10 points)
- test4: checks fourth line of output with the prompt and Weight entered by user. (10 points)
- test5: checks fifth line of output with the prompt and Lovibond entered by user. (10 points)
- test6: checks sixth line of output with the prompt and Volume entered by user. (10 points)
- test7: checks seventh line of output with the SRM value. (10 points)
- Final Tests
Final tests use arbitrary values for all inputs.
- test6: checks third line of output with the HBUs. (10 points)
- test7: checks Last line of output with the SRM value. (10 points)
- test8: checks third line of output with the HBUs for different input. (5 points)
- test9: checks Last line of output with the SRM value for different input. (5 points)
- Final grading includes the preliminary tests.
Submit P2.java to Checkin.