answer.
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
Olenka [21]
1 year ago
7

Program MATH_SCORES: Your math instructor gives three tests worth 50 points each. You can drop one of the test scores. The final

grade is the sum of the two best test scores. Assuming the three test scores are input from the keyboard, write an interactive program that asks the user to enter three test scores and then calculates the final letter grade using the following cut-off points. >=90 A <90, >=80 B <80, >=70 C <70, >=60 D < 60 F Input validation: Display an error message if the user enters a score greater than 50 and do not accept negative values.
Computers and Technology
1 answer:
Simora [160]1 year ago
8 0

Answer:

import java.util.Scanner;

public class num5 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       //Prompt and receive the three Scores

       int score1;

       int score2;

       int score3;

       do {

           System.out.println("Enter first Score Enter score between 1 -50");

           score1 = in.nextInt();

       } while(score1>50 || score1<0);

       do {

           System.out.println("Enter second Score.The second score must be between 1 -50");

           score2 = in.nextInt();

       } while(score2>50 || score2<0);

       do {

           System.out.println("Enter Third Score Third score must between 1 -50");

           score3 = in.nextInt();

       } while(score3>50 || score3<0);

       //Find the minimum of the three to drop

       int min, min2, max;

       if(score1<score2 && score1<score3){

           min = score1;

           min2 = score2;

           max = score3;

       }

       else if(score2 < score1 && score2<score3){

           min = score2;

           min2 = score1;

           max = score3;

       }

       else{

           min = score3;

           min2 = score1;

           max = score2;

       }

       System.out.println("your entered "+max+", "+min2+" and "+min+" the min is");

       int total = max+min2;

       System.out.println("Total of the two highest is "+total);

       //Finding the grade based on the cut-off points given

       if(total>=90){

           System.out.println("Grade is A");

       }

       else if(total>=80){

           System.out.println("Grade is B");

       }

       else if(total>=70){

           System.out.println("Grade is C");

       }

       else if(total>=60){

           System.out.println("Grade is D");

       }

       else{

           System.out.println("Grade is F");

       }

   }

}

Explanation:

  • Implemented with Java
  • Use the scanner class to receive user input
  • Use a do.....while loop to validate user input for each of the variables. A valid score must be between 0 and 50 while(score>50 || score<0);  
  • Use if and else to find the minimum of the three values and drop
  • Add the two highest numbers
  • use if/else if /else statements to print the corresponding grade
You might be interested in
A cyber criminal sends a series of maliciously formatted packets to the database server. The server cannot parse the packets and
telo118 [61]

Answer:

DoS attack

Explanation:

A Denial of Service attack involves the sending of maliciously formatted data packets to a server. The packet can be larger than the allowed IP size such that when it arrives at the server, the server cannot identify the headers in the data packet for it to process and extract data. The server can either freeze or crash, denying allowed users access to its resources and making it unavailable.

7 0
1 year ago
Alice just wrote a new app using Python. She tested her code and noticed some of her lines of code are out of order. Which princ
LenKa [72]

Answer:

This is Elijah from FLVS hihi :DDDDDDDDDDDDDDDDDDDDDDDDDDDDD CVS

Explanation:

6 0
2 years ago
Make a class Employee with a name and salary. Make a class Manager inherit from Employee. Add an instance variable, named depart
sweet [91]

Answer:

see explaination

Explanation:

class Employee

{

String name;

double salary;

void tostring()

{

System.out.println("Employee:\nName: "+name+"\nSalary: "+salary+"\n");

}

Employee(String n,double s)

{

name=n;

salary=s;

}

}

class Manager extends Employee

{

String department;

void tostring()

{

System.out.println("Manager:\nName: "+name+"\nDepartment: "+department+"\nSalary: "+salary+"\n");

}

Manager(String n,double s,String d)

{

super(n,s);

department=d;

}

}

class Executive extends Manager

{

void tostring()

{

System.out.println("Executive:\nName: "+name+"\nDepartment: "+department+"\nSalary: "+salary+"\n");

}

Executive(String n,double s,String d)

{

super(n,s,d);

}

}

public class test

{

public static void main(String args[])

{

Employee e =new Employee("Neo",12000);

e.tostring();

Manager m =new Manager("Cramster",100000,"Homework");

m.tostring();

Executive ex =new Executive("Chuks",1000000,"Homework");

ex.tostring();

}

}

8 0
1 year ago
Karin realized that a song takes up a lot more space on her computer than the lyrics of the song typed out in ms word document .
Nitella [24]
Consider that there are many different components of one file such as a song rather than a word document of typed words. Research the components of why this song takes up space on a computer.
5 0
1 year ago
Using basic programming (for loops, while loops, and if statements), write two MATLAB functions, both taking as input:
borishaifa [10]

Answer:

For n = 100

  • (AB)x: 10100
  • A(Bx): 200

For n = 200

  • (AB)x: 40200
  • A(Bx): 400

For n = 400

  • (AB)x: 160400
  • A(Bx): 800

For n = 800

  • (AB)x: 640800
  • A(Bx): 1600

The faster approach is A(Bx)

Explanation step by step functions:

A(Bx) is faster because requires fewer interactions to find a result: for (AB)x you have (n*n)+n interactions while for A(Bx) you have n+n, to understand why please see the step by step:

a) Function for (AB)x:

function loopcount1 = FirstAB(A,B,x)  

 n = size(A)(1);

 AB = zeros(n,n);

 ABx = zeros(n,1);

 loopcount1 = 0;  

 for i = 1:n

   for j = 1:n

     AB(i,j) = A(i,:)*B(:,j);

     loopcount1 += 1;

   end

 end

 for k = 1:n

   ABx(k) = AB(k,:)*x;

   loopcount1 += 1;

 end

end

b) Function for A(Bx):

function loopcount2 = FirstBx(A,B,x)

 n = size(A)(1);

 Bx = zeros(n,1);

 ABx = zeros(n,1);

 loopcount2 = 0;  

 for i = 1:n

   Bx(i) = B(i,:)*x;

   loopcount2 += 1;

 end

 for j = 1:n

   ABx(j) = A(j,:)*Bx;

   loopcount2 += 1;

 end

end

5 0
2 years ago
Other questions:
  • 1. Accessing calendars, contact information, emails, files and folders, instant messages, presentation, and task lists over the
    12·1 answer
  • Peter accumulated many photos from his visit to Wisconsin. He wants to upload these photos to a social networking site. Which fi
    12·1 answer
  • Remember that ""state space"" refers to the space of all potential possibilities. Which dichotomous questions below will success
    5·1 answer
  • A common fallacy is to use MIPS (millions of instructions per second) to compare the performance of two different processors, an
    15·1 answer
  • The following checksum formula is widely used by banks and credit card companies to validate legal account numbers: d0 + f(d1) +
    13·1 answer
  • Suppose two threads execute the following C code concurrently, accessing shared variables a, b, and c: Initialization int a = 4;
    15·1 answer
  • 1⁰=?<br> Is equal to...........
    12·2 answers
  • Select all the activities Samil could so through his banking app.
    5·2 answers
  • In this image, which feature did we most likely use to quickly change the background, fonts, and layout?
    6·1 answer
  • An employee sets up an automation that transfers files in a specific folder on their PC to a remote drive for archiving, provide
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!