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...

  • Course,java import java.util.ArrayList; import java.util.Arrays; /* * To change this license header, choose License Headers in...

    Course,java import java.util.ArrayList; import java.util.Arrays; /* * 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. */ /** * * @author fenghui */ public class Course {     private String cName;     private ArrayList<Subject> cores;     private ArrayList<Major> majors;     private ArrayList<Subject> electives;     private int cCredit;          public Course(String n, int cc){         cName = n;         cCredit = cc;         cores = new ArrayList<Subject>(0);         majors =...

  • 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...

  • JAVA project PLEASE complete/ create project with comments in the programming explaining everything Text file Year...

    JAVA project PLEASE complete/ create project with comments in the programming explaining everything Text file Year of storm/ Name of storm/ mmdd storm started/ mmdd storm ended/ magnitude of storm/ //made up data 2004/Ali/1212/1219/1 2003/Bob/1123/1222/3 1980/Sarah/0123/0312/0 1956/Michael/1211/1223/4 1988/Ryan/0926/1019/ 1976/Tim/0318/1010/0 2006/Ronald/0919/1012/2 1996/Mona/0707/0723/1 2000/Kim/0101/0201/1 2001/Jim/1101/1201/3 Text file Class storm{ private String nameStorm; private int yearStorm; private int startStorm; private int endStorm; private int magStorm; public storm(String name, int year, int start, int end, int mag){ nameStorm = name; yearStorm = year; startStorm...

  • Need C++ coding for this lab exercise given below :) 4. Lab Exercise — Templates Exercise...

    Need C++ coding for this lab exercise given below :) 4. Lab Exercise — Templates Exercise 1 - Function Templating For this part of the lab make a template out of the myMax function and test it on different data types. Copy maxTemplate.cpp to your Hercules account space. Do that by: Entering the command:cp /net/data/ftp/pub/class/115/ftp/cpp/Templates/maxTemplate.cpp maxTemplate.cpp Compile and run the program to see how it works. Make a template out of myMax. Don't forget the return type. Modify the prototype appropriately. Test your myMax template on int, double,...

  • pls help java ASAP!!!!!!! Topic String Tokenizer Static Methods Static Variables Primitive Arrays Description Enhance the...

    pls help java ASAP!!!!!!! Topic String Tokenizer Static Methods Static Variables Primitive Arrays Description Enhance the last assignment by providing the following additional features: (The additional features are listed in bold below) Class Statistics In the class Statistics, create the following static methods (in addition to the instance methods already provided). • A public static method for computing sorted data. • A public static method for computing min value. • A public static method for computing max value. • A...

  • 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...

  • 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...

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
ADVERTISEMENT