CIS 120 Exam 2 Programming Question.

Added on - 18 Sep 2019

  • 1


  • 467


  • 106


  • 0


Trusted by +2 million users,
1000+ happy students everyday
Showing pages 1 to 1 of 1 pages
CIS 120 Exam 2 Programming QuestionCreate a new Project and Class called Exam2_YourName. Please write your name in the class name.Your program will have a main method and two other methods called gradeCalculator andcalculateAverage. Submit all the .java file called Exam2_YourName. Also ,copy and paste your codeinto a .docx file and upload the file as well. Please use the exam2 dropbox to submit your code.Yourmainmethod does the following :1)Create a 5-element array calledsubjectMarksthat will carry numeric marks (double data type)of a student in five different subjects. Each mark can be a real number such as 40.5, 35.6 etc.Declare the array appropriately.2)Fill the array with values: Prompt the user to enter the student’s mark in each subject, one byone and use those values to fill the elements of thesubjectMarksarray one by one.3)Call thecalculateAveragemethod and pass on thesubjectMarksarray as a parameter. Thismethod will return the average mark of the student. Print out the average mark of the studenton the console with proper comments. Use any required variable (for example- name itavgMark) to store the average mark value returned by the method.4)Call thegradeCalculatormethod and pass on to this method as a parameter, the variable thatcontains the average mark (avgMarkas obtained in step 3). This method (gradeCalculator )calculates the letter grade based on the student’s average and returns a String that will be theletter grade of the student. Print out this letter grade into the console. You may use a variablenameletterGradeto hold the letter grade returned by the method.Write the code for thecalculateAveragemethod. ThecalculateAveragemethod has the followingfeatures:1)This method will take in as a parameter/argument the array containing marks of the student (as insubjectMarksarray).2)This method returns a double value corresponding to the average marks of the student. You maydeclare a double variable calledavgMarkthat will contain the average marks.3)This method calculates the average marks by taking one element of the array at a time, addingthem to find the total marks. You may use a variable calledtotalMarkto hold the total mark. Afteradding all the elements (,or marks), divide the total marks with the length of the array ( which givesthe number of subjects), to obtain the average marks. Return the average marks carried by thevariableavgMarks.Anastasia Declin
You’re reading a preview
Preview Documents

To View Complete Document

Click the button to download
Subscribe to our plans

Download This Document