(solution) Assignment #1 Due Tuesday, Sept 20 at 3:30 pm COMP1006/1406 –

(solution) Assignment #1 Due Tuesday, Sept 20 at 3:30 pm COMP1006/1406 –

i need help on my assignment, its in java and i have no clue on what to do, this is my first assignment and i’ve been trying to work on it for a while now but i could’nt, i thought of not submitting it but i thought of giving it a shot and try to get help, i have attached all files needed for it. please i really need help

Assignment #1 Due Tuesday, Sept 20 at 3:30 pm COMP1006/1406 ? Fall 2016
Submit a single file called assignment1.zip to cuLearn.
There are 30 marks possible marks.
In assignment specifications, text appearing like this represents things that a user
types when running or using a program. Text that appears like this represents output
from your program. 1: Final Grade Computation [10 marks]
Write a program that computes a final grade, as specified in the course outline using the
four term marks: assignments, tutorials, midterma and final exam.
The four term marks will be provided to the program via command line arguments (values passed to the program when you run the program from the console window in DrJava)
and will always be given in the same order: A, T, M, F.
è Starting with the skeleton program provided, Grades.java, add code to the computeGrade
and roundGrade methods so that the program outputs to standard output (System.out) the
correct final grade. Do not change the main method. Your program will output a single line
with the computed final grade rounded to exactly one decimal place. The grades provided
from the command line can be integers or decimal numbers (all are given as a percentage).
To allow for possible bonus marks, valid percentages can range from 0.0 to 105.0. The
roundGrade function will take a double and return a string that represents that number
rounded to exactly one decimal place.
Add comments, whitespace, and indentation to the code so that the entire file (Grades.java),
not just the functions you are completing, follows the style guide. Marks will be deducted if
you do not follow the style guide.
Examples: From the console window in DrJava (or from a shell),
java Grades 78.1 63.2 80.3 78 will output the single line 77.2
java Grades 50 105 50 50 will output the single line 55.5
java Grades 105 105 1 98 will output the single line 49.5 Testing: Create and submit another program called GradesTesting, that tests your Grades
program. For each test case, your program should display the input (grades), the expected
output of your program and the actual output. For example, a single test case might look like
String input = {"78.1", "63.2", "80.3", "78" };
System.out.println("Test 0: " + java.util.Arrays.toString(input)); System.out.println(" Expected answer is 77.2");
System.out.println(" Answer obtained is " + Grades.main(input)); COMP1006/1406 – Fall 2016 1 Assignment #1 Due Tuesday, Sept 20 at 3:30 pm Your testing program should also follow the style guide. In particular, be sure you
describe (in comments) each test case (or group of test cases). The expected and actual
output should line up nicely on the screen.
Mark breakdown: 3 marks for Style, 3 marks for Testing, 4 marks for Correctness
Include both your Grades.java and GradesTesting.java files in your submission
assignment1.zip file. 2: Grade Conversion [10 marks]
è In the provided Convert.java file, complete the two methods: convertToLetter and
convertToGradePoint. The interface (specification) of the methods are given below.
public static String convertToLetter(double grade)
/* Purpose: converts a given numerical grade to a letter grade
* Input : a number
* output : the letter grade (F, D-, D, …, A+) corresponding to the
*
input grade if the input is valid, "Invalid" otherwise *
*
*
*/ public static int convertToGradePoint(String letterGrade)
/* Purpose: converts a given leter grade to its equivalent grade point
* Input : A valid letter grade in the range D- to A+ (no F?s)
* output : The grade point corresponding to the input letter grade
*
Use 0 for F and -1 for Invalid input
* Note
: you MUST use a switch/case for this method *
*
*
*
*/ The conversion table is given as follows
Letter
A+
A
AB+
B
BC+
C
CD+
D
DF
Invalid Grade Range
[90, 100]
[85, 90)
[80, 85)
[77, 80)
[73, 77)
[70, 73)
[67, 70)
[63, 67)
[60, 63)
[57, 60)
[53, 57)
[50, 53)
[0, 50)
other Grade Point
12
11
10
9
8
7
6
5
4
3
2
1
0
-1 Note that the range [a, b) means any number x such that a ? x < b. That is, square
brackets mean inclusive and parentheses mean exclusive.
Mark breakdown: 2 marks for Style, 8 marks for Correctness COMP1006/1406 – Fall 2016 2 Assignment #1 Due Tuesday, Sept 20 at 3:30 pm Put your Convert.java file in your assignment1.zip file. Examples:
returns Convert.convertToLetter(60.0) ????? Creturns Convert.convertToGradePoint("C-") ????? 4
returns Convert.convertToLetter(49.9) ????? F
returns Convert.convertToGradePoint("F") ????? 0 3: Longest Streak [10 marks]
è In the provided LongestStreak.java file, complete the following method: public static
/* Purpose :
*
* Inputs :
* Outputs :
*
*
*
*
*
* int longestStreak(boolean values)
computes the length and locations of all the maximal
sequences of consecutive true occurrences in values
values is a non-null array of booleans with length at least 1
outputs an integer array with one or more elements
– first element is the length of a maximal sequence of
consecutive trues in the input array values
– the next elements are the indexes of the starting points
(in the input array values) of each of the maximal
sequences of consecutive trues
if there are no true values in the input array, output [0] *
*
*
*
*
*
*
*
*
*/ Do not change the method signature (use the provided skeleton java file). Changing the method modifiers,
return type, name or input arguments will result in zero correctness marks for this problem.
Mark breakdown: 2 for style, 8 for correctness
Put your LongestStreak.java file in your assignment1.zip file.
Examples:
boolean test case = {true, false, true, false, true};
returns LongestStreak.longestStreak( test case ) ????? [1,0,2,4]
test case = new boolean{false, false, false, true, true};
returns LongestStreak.longestStreak( test case ) ????? [2,3] Submission Recap
A complete assignment will consist of a single file (assignment1.zip) with the following four (4) files
included: Grades.java, GradesTesting.java, Convert.java, and LongestStreak.java. COMP1006/1406 – Fall 2016 3