Question

Java Programming

Question 6 Not yet answered A) What are the parameters of assessment)? Marked out or 20.00 P Flag question Submit the impleme

Lab 07 coding

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package lab07;

/**
*
* @author ckandjimi
*/
public class Lab07 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {

int outcome = methodX(5);
System.out.printf("Result from Method X= %d",outcome);
String [] studentNames = {"Kingston","John","Nangula","Daniela"};
int Test01[] = {59,72,70,66};
int Test02[] = {80,65,55,49};
  
/**TASKS
* 1. Implement the 2 methods below assessment and highestMark
* 2. Using the 3 arrays declared above invoke or make a method call to assessment
* 3. Invoke highestMark using Test01 or Test02 arrays and store the results in test01Highest,
* test02Highest respectively
* 4. methodX has been fully implemented and Line 19 above makes a call to that function,
* create a table and record the outcomes when the function is called with the following
* arguments : methodX(-5) and methodX(0)
*
*/
  
  
  
}
public static void assessment(/*ADD YOUR PARAMETERS HERE*/){
/**
* This Function takes in 3 arrays one for student names, and 2 for the respective test marks
* We would like to print a list of students names,Test 01,Test 02 and final marks for each
* students(See sample), The final mark is 40% Test 01 and 60% Test 02.
* In the end we would like to print the sub total of all marks and average
* Use the below format for you print out:
* Name Test 01 Test 02 Final
* -------- ------- ------- -------
* Kingston 59 80 72
* John 72 65 68
* ----------------------------------------
* Sub-total 140
* Average 70
* ----------------------------------------
*/
  
}
public static int highestMark(/*ADD YOUR PARAMETERS HERE*/){
/**
* This Functions takes in an array of Marks and return the highest mark
*/
return 0; //Change this statement
}
public static int methodX(int n){
/**
* This function uses recursion to do some interesting calculations
* if the given number(n) is equal or less then 1 the functions returns 1(Stopping case)
* other wise the number(n) is multiplied by the result of the function methodX(n-2)
*/
if (n <= 1 )
return 1;
else
return n * methodX(n-2);
}
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

code self understandable

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package lab07;


/**
*
* @author ckandjimi
*/
public class Lab07 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {

int outcome = methodX(5);
System.out.printf("Result from Method X= %d",outcome);
String [] studentNames = {"Kingston","John","Nangula","Daniela"};
int Test01[] = {59,72,70,66};
int Test02[] = {80,65,55,49};
int Test01Highest=highestMark(Test01);
int Test02Highest=highestMark(Test02);
/**TASKS
* 1. Implement the 2 methods below assessment and highestMark
* 2. Using the 3 arrays declared above invoke or make a method call to assessment
* 3. Invoke highestMark using Test01 or Test02 arrays and store the results in test01Highest,
* test02Highest respectively
* 4. methodX has been fully implemented and Line 19 above makes a call to that function,
* create a table and record the outcomes when the function is called with the following
* arguments : methodX(-5) and methodX(0)
*
*/
System.out.println();
assessment(studentNames,Test01,Test02);
System.out.println("Method(-5) = "+methodX(-5));
System.out.println("Method(0) = "+methodX(0));
  
  
}
public static void assessment(String studentNames [],int test01[],int test02[]){
/**
* This Function takes in 3 arrays one for student names, and 2 for the respective test marks
* We would like to print a list of students names,Test 01,Test 02 and final marks for each
* students(See sample), The final mark is 40% Test 01 and 60% Test 02.
* In the end we would like to print the sub total of all marks and average
* Use the below format for you print out:
* Name Test 01 Test 02 Final
* -------- ------- ------- -------
* Kingston 59 80 72
* John 72 65 68
* ----------------------------------------
* Sub-total 140
* Average 70
* ----------------------------------------
*/

System.out.println("Name Test 01 Test 02 Final");
int sub_total=0;
for(int i=0;i<studentNames.length;i++)
{
  
   float x=(float)0.4*test01[i]+(float)0.6*test02[i];
   System.out.println(studentNames[i]+" "+test01[i]+" "+test02[i]+" "+Math.round(x));
   sub_total+=Math.round(x);
}
System.out.println("Sub-total "+sub_total);
System.out.println("Average "+(float)sub_total/studentNames.length);
}
public static int highestMark(int arr[]){
/**
* This Functions takes in an array of Marks and return the highest mark
*/
int highest=arr[0];
for(int i=0;i<arr.length;i++)
{
   if(arr[i]>highest)
   highest=arr[i];
}
return highest; //Change this statement
}
public static int methodX(int n){
/**
* This function uses recursion to do some interesting calculations
* if the given number(n) is equal or less then 1 the functions returns 1(Stopping case)
* other wise the number(n) is multiplied by the result of the function methodX(n-2)
*/
if (n <= 1 )
return 1;
else
return n * methodX(n-2);
}
}

a)The parameters of assesement are String studentNames [],int test01[],int test02[]

b)The parameters of highestMarks is a marks array either Test01 or Test02

c)Make a variable highest equal to first student marks

and for the rest of the students follow this condition if(highest<marks[i]) highest=marks[i]

d)

Arguments outcome

5 15

-5 1

0 1

e)

when n=5

it will return 5*methodX(3)

methodX(3) will return 3*methodX(1)

methodX(1) will return 1

so methodX(3)=3*1=3

and methodX(5)=5*3=15

Add a comment
Know the answer?
Add Answer to:
Java Programming Lab 07 coding /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in th...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question 6 (lab 07) /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. *...

    Question 6 (lab 07) /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package lab07; /** * * @author ckandjimi */ public class Lab07 { /** * @param args the command line arguments */ public static void main(String[] args) { int outcome = methodX(5); System.out.printf("Result from Method X= %d",outcome); String [] studentNames = {"Kingston","John","Nangula","Daniela"}; int Test01[] =...

  • /* * To change this license header, choose License Headers in Project Properties. * To change...

    /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package checkingaccounttest; // Chapter 9 Part II Solution public class CheckingAccountTest { public static void main(String[] args) {    CheckingAccount c1 = new CheckingAccount(879101,3000); c1.deposit(350); c1.deposit(220); c1.withdraw(100); c1.deposit(1100); c1.deposit(700); c1.withdraw(350); c1.withdraw(220); c1.withdraw(100); c1.deposit(1100); c1.deposit(700); c1.deposit(1000); System.out.println(c1); System.out.println("After calling computeMonthlyFee()"); c1.computeMonthlyFee(); System.out.println(c1); } } class BankAccount { private int...

  • Java Programming The program template represents a complete working Java program with one or more key...

    Java Programming The program template represents a complete working Java program with one or more key lines of code replaced with comments. Read the problem description and examine the output, then study the template code. Using the problem-solving tips as a guide, replace the /* */ comments with Java code. Compile and execute the program. Compare your output with the sample output provided. Modify class Time2 to include a tick method that increments the time stored in a Time2 object...

  • Lab 1.java only Goal: This lab will give you experience with defining and using classes and...

    Lab 1.java only Goal: This lab will give you experience with defining and using classes and fields, and with conditionals and recursive functions. Getting Started --------------- Read the Fraction.java class into a text editor and compile it filling in the command javac -g Fraction.java. The program should compile without errors. In a shell window, run the program using "java Fraction". The program should run, although it will print fractions in a non-reduced form, like 12/20. Part I: Constructors (1 point)...

  • Programming Project #5 Project Outcomes: Develop a Java program that Uses selection constructs (if, and if...

    Programming Project #5 Project Outcomes: Develop a Java program that Uses selection constructs (if, and if else). Uses the Java iteration constructs (while, do, for). Uses static variables. Ensure integer variables input are within a range that will not cause integer overflow. Uses proper design techniques including reading UML Class Diagrams Background Information: The Unified Modeling Language (UML) provides a useful notation for designing and developing object-oriented software systems. One of the basic components of the UML is a class...

  • CSC110 Lab 6 (ALL CODING IN JAVA) Problem: A text file contains a paragraph. You are to read the contents of the file, store the UNIQUEwords and count the occurrences of each unique word. When the fil...

    CSC110 Lab 6 (ALL CODING IN JAVA) Problem: A text file contains a paragraph. You are to read the contents of the file, store the UNIQUEwords and count the occurrences of each unique word. When the file is completely read, write the words and the number of occurrences to a text file. The output should be the words in ALPHABETICAL order along with the number of times they occur and the number of syllables. Then write the following statistics to...

  • Using Merge Sort: (In Java) (Please screenshot or copy your output file in the answer) In...

    Using Merge Sort: (In Java) (Please screenshot or copy your output file in the answer) In this project, we combine the concepts of Recursion and Merge Sorting. Please note that the focus of this project is on Merging and don't forget the following constraint: Programming Steps: 1) Create a class called Art that implements Comparable interface. 2) Read part of the file and use Merge Sort to sort the array of Art and then write them to a file. 3)...

  • For this lab you will write a Java program that plays the dice game High-Low. In...

    For this lab you will write a Java program that plays the dice game High-Low. In this game a player places a bet on whether the sum of two dice will come up High (totaling 8 or higher), Low (totaling 6 or less) or Sevens (totaling exactly 7). If the player wins, they receive a payout based on the schedule given in the table below: Choice Payout ------ ------ High 1 x Wager Low 1 x Wager Sevens 4 x...

  • The file containing the JAVA files, pseudocode file and doc file that have written for this...

    The file containing the JAVA files, pseudocode file and doc file that have written for this lab. Preamble The file releasedates.txt contains a list of video games and their release dates. Each line of the file contains the release date, a tab character, and then the name. The list is currently totally unsorted. The object of today's lab is to write a series of methods that allow us to perform the following tasks: read contents from a file and store...

  • Java Program Note: no break statements or switch staements High, Low, Sevens For this lab you...

    Java Program Note: no break statements or switch staements High, Low, Sevens For this lab you will write a Java program that plays the dice game High-Low. In this game a player places a bet on whether the sum of two dice will come up High (totaling 8 or higher), Low (totaling 6 or less) or Sevens (totaling exactly 7). If the player wins, they receive a payout based on the schedule given in the table below: Choice Payout ------...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT