1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
sukhopar [10]
3 years ago
15

Public static Object[] question4(Student student1, Student student2)

Computers and Technology
1 answer:
Archy [21]3 years ago
5 0

Answer:

Complete code is given below:

Explanation:

public static Object[] question4(Student student1, Student student2){

  /* For this exercise you will be using for loops to calculate various values.

  You will be making use of the following object references which are passed as arguments to this method:

  A Student object reference student1

  A Student object reference student2

  You will need to use various accessor methods of the Student class to complete this assignment.

  Additional variables that you will use have already been declared.

  1) Set the value of student1HighestGrade to the highest grade for student1

  2) Set the value of student2HighestGrade to the highest grade for student2

  3) Set the value of student1AverageGrade to the average grade for student1

  4) Set the value of student2AverageGrade to the average grade for student2

  5) Assign the bestHighGradeStudent object reference whichever student has the best high grade

  6) Assign the bestAverageGradeStudent object reference whichever student has the best average grade

  This program contains a main method that can be used to manually test your code by right-clicking Question4.java

  and selecting "Run File"    

  */

 

  int student1HighestGrade, student2HighestGrade;

  double student1AverageGrade, student2AverageGrade;

  Student bestAverageGradeStudent, bestHighGradeStudent;

 

  // Your code goes Here:

 

 

 

  //FINDING HIGHEST GRADE OF STUDENT 1

  student1HighestGrade = -1;   //initially set to minimum

  //iterating through all 8 grades

  for(int i = 0; i < 8; i++){

      //current highest grade is less than ith grade

      if(student1.getExamScore(i) > student1HighestGrade){

          //making ith grade as the highest grade

          student1HighestGrade = student1.getExamScore(i);

      }

  }

 

  //FINDING HIGHEST GRADE OF STUDENT 1

  student2HighestGrade = -1;   //initially set to minimum

  //iterating through all 8 grades

  for(int i = 0; i < 8; i++){

      //current highest grade is less than ith grade

      if(student2.getExamScore(i) > student2HighestGrade){

          //making ith grade as the highest grade

          student2HighestGrade = student2.getExamScore(i);

      }

  }

 

  //FINDING THE GRADE SUM OF STUDENT 1

  student1AverageGrade = 0;   //setting grade sum as 0 initially

  //iterating through all 8 grades

  for(int i = 0; i < 8; i++){

      //adding ith grade to tha total grade sum

      student1AverageGrade += student1.getExamScore(i);

  }

  //FINDING THE AVERAGE GRADE OF STUDENT 1

  student1AverageGrade /= 8;

 

 

  //FINDING THE GRADE SUM OF STUDENT 2

  student2AverageGrade = 0;   //setting grade sum as 0 initially

  //iterating through all 8 grades

  for(int i = 0; i < 8; i++){

      //adding ith grade to tha total grade sum

      student2AverageGrade += student2.getExamScore(i);

  }

  //FINDING THE AVERAGE GRADE OF STUDENT 2

  student2AverageGrade /= 8;

 

 

  //FINDING THE BEST HIGHEST GRADE STUDENT

  if(student1HighestGrade > student2HighestGrade){

      //student1's highest grade is greater than student2's highest grade

      //Best highest grade student is student1

      bestHighGradeStudent = student1;

  }

  else{

      //Best highest grade student is student2

      bestHighGradeStudent = student2;

  }

 

 

  //FINDING THE BEST AVERAGE GRADE STUDENT

  if(student1AverageGrade > student2AverageGrade){

      //student1's average grade is greater than student2's highest grade

      //Best average grade student is student1

      bestAverageGradeStudent = student1;

  }

  else{

      //Best average grade student is student2

      bestAverageGradeStudent = student2;

  }

 

 

 

  // Necessary for Unit Test

  return new Object[] {student1HighestGrade, student2HighestGrade, student1AverageGrade, student2AverageGrade, bestHighGradeStudent, bestAverageGradeStudent};

  }

You might be interested in
"Write a program that calculates the balance of a savings account at the end of a period of time. It should ask the user for the
Akimi4 [234]

Answer:

#include <iostream>

#include <fstream>

using namespace std;

int main() {

// Definitions

       double annualInterest;          // The annual interest rate

       double balance;                 // The account balance

       int months;                     // Total number of months

       double totalDeposit  = 0.0;     // Total deposited value

       double totalWithdraw = 0.0;     // Total withdrawn value

       double earnedInterest= 0.0;     // The earned amount

       double deposited;               // Monthly deposited value

       double withdrawn;               // Monthly withdrawn value

// Get the initial required data.

       

       cout<<"Please enter the annual interest rate,\n";

       cout<<"   Interest rate: ";

       cin >>annualInterest;

       cout<<"--------------------------------------------\n";

       cout<<"Please enter the starting balance,\n";

       do{

           cout<<"[the number could not be negative]\n";

           cout<<"Starting Balance: ";

           cin >>balance;

       }while(balance<0);

       cout<<"--------------------------------------------\n";

       cout<<"Please enter the number of months,\n";

       do{

           cout<<"[the number could not be less than 0]\n";

           cout<<"Number of months: ";

           cin >>months;

       }while(months<0);

// Iterated Loop to get all the months data.

       for(int month=1; month <= months; month++){

// Get the deposited value during that month.

           cout<<"Enter the deposited value during month "

               <<month<<",\n";

           do{

               cout<<"[the value could not be less than 0]\n";

               cout<<" Deposited value: ";

               cin >>deposited;

           }while(deposited<0);

           

           totalDeposit += deposited;

           balance += deposited;

// Get the withdrawn value during that month.

           cout<<"Enter the withdrawn value during month "

               <<month<<",\n";

           do{

               cout<<"[the value could not be less than 0]\n";

               cout<<" Withdrawn value: ";

               cin >>withdrawn;

           }while(withdrawn<0);

           

           totalWithdraw += withdrawn;

           balance -= withdrawn;

// Negative balance close the program.

           if(balance < 0){

               cout<<"Sorry, the account has been closed due to\n";

               cout<<"the negative balance.\n";

                 break;

// Calculate value due to the interest rate.

           }

      else {

               earnedInterest += (annualInterest/12) * balance;

               //        monthly interest rate

               balance += (annualInterest/12) * balance;

           }

       }

  // Display the statistics,

      ofstream file;

      file.open ("Report written to Report.txt");

      file << "Report written to Report.txt\n";

       file.close();

       cout<<"The ending balance: "<<balance<<std::endl;

       cout<<"   Total deposited: "<< totalDeposit<<std::endl;

       cout<<" Total withdrawals: "<< totalWithdraw<<std::endl;

       cout<<"   Earned interest: "<< earnedInterest<<std::endl;

       cout<<"============================================\n";

 return 0;

   }

   

6 0
3 years ago
If your DTP document contains watermarks on every page, where can you place them?
QveST [7]

Answer:

<h3>You can place watermarks and other recurring elements on a DTP document by following the points below:</h3><h3 />
  • Open the DTP document on which watermark is to be placed.
  • Click on Page Layout tab
  • Locate the Page Background group and click it.
  • Select the Watermark Option and then select Custom watermark.
  • A box will open when you click the Text Watermark.
  • Type the text you want and click on Insert.
  • All other changes can be done using options.

<h3>I hope it will help you!</h3>

6 0
3 years ago
This is for C++: Using a nested for loop output the following pattern to the screen:
olga55 [171]

Answer:

Following are the code to the given question:

#include <iostream>//header file

using namespace std;

int main()//main method

{

int r=26,x,y;//defining integer variable  

char c;//defining a character variable

for(x= 1; y<= r; x++)//using for loop for count value

{

for(y= 1; y<= x; y++)//using for loop to convert value in triangle  

{

c=(char)(y+64);//convert value into character  

cout << c;//print character value

}

cout << "\n";//use print method for line break

}

return 0;

}

Output:

Please find the attachment file.

Explanation:

In this code, three integer variable "x,y, and r", and one character variable "c" is declared, that is used in the nested for loop,  in the first for loop it counts the character value and in the next for loop, it converts the value into a triangle and uses the char variable to print its character value.

3 0
3 years ago
A database planner names a field “Organic ingredients_3”. Why would this name Create possible problems in programming?
o-na [289]

Answer:

I think the answer is 2.

hope it will help you

4 0
3 years ago
Read 2 more answers
Hello! I am a new coder, so this is a simple question. But I am trying to create a code where you enter a number, then another n
slavikrds [6]

no longer returns an error but your math seems to have something wrong with it, always returns 0

Console.WriteLine("Enter a percentage here");

   int Percent = int.Parse(Console.ReadLine());

   Console.WriteLine("Enter your number here");

   int Number = int.Parse(Console.ReadLine());

   int result = Percent / 100 * Number;

6 0
3 years ago
Other questions:
  • You are entering command that operates on a file. The path to the file is lengthy and confusing and you are afraid that you will
    12·1 answer
  • This is for the folks that is rude:
    12·1 answer
  • When transporting data from real-time applications, such as streaming audio and video, which field in the ipv6 header can be use
    12·1 answer
  • What could be one rule to help your friend to blog safely
    6·2 answers
  • 2. Integer plot function (find a smart way to code big integers) Write a program BigInt(n) that displays an arbitrary positive i
    8·1 answer
  • Given two strings s and t of equal length, the Hamming distance between s and t, denoted dH(s,t), is the number of corresponding
    6·1 answer
  • Which of the following contributes to your active digital footprint
    12·2 answers
  • Convert 198 / 61 to ratio​
    9·1 answer
  • Did you know a security hacker is someone who explores methods for breaching defenses and exploiting weaknesses in a computer sy
    11·2 answers
  • oe, a user, receives an email from a popular video streaming website. the email urges him to renew his membership. the message a
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!