Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What is wrong with the following code? public static String grade(int score) { if (score >= 9) { return A; } else if (score >=

image text in transcribed
image text in transcribed
What is wrong with the following code? public static String grade(int score) { if (score >= 9) { return A; } else if (score >= 8) { return B; } else if (score >= 6) { return C; } else if (score >= 4) { return D; } return f; } Invalid argument in return statements No return statement for all branches of "if" statement " Invalid parameter variable type O illegal method name A programmer notices that the following code snippet uses the same algorithm for computing interest earned, but with different variables, in the two places shown below and in several other places in the program. What could be done to improve the program? final double RATE1 final double RATE2 - 5.5; double interest - investment + RATEL / 100; balance - balance + balance + RATE2 / 100; 10; Declare the rates as variables, not constants. Define a method that looks up interest rates. Define a method that prompts the user for an amount and a rate of interest, then returns the interest earned. Define a method that computes the interest earned from an amount and a rate of interest

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions

Question

Approaches to Managing Organizations

Answered: 1 week ago