Path: p Words:0 QUESTION 17 A salesperson earns a bonus of 1% of their sales if
ID: 3726932 • Letter: P
Question
Path: p Words:0 QUESTION 17 A salesperson earns a bonus of 1% of their sales if they made at least $100,000 in sales but less than $1,000,000 of sales. The salesperson earns a bonus of 296 if he or she makes $1,000,000 or more in sales. No bonus is earned if the salesperson made less than $100,000 in sales. Assuming an integer value named sales contains the amount of sales in dollars, write an if/else statemen bonus variable can store decimal places, and ignore rounding to the nearest cent. t that sets the appropriate bonus value in a variable named bonus. Assume the Words:0 Path: p QUESTION 18 Write a single line of Java code to create an object called account from the CheckingAccount class. Assume the classExplanation / Answer
17.
import java.io.*;
class GFG {
public static void main (String[] args) {
int sales=105455;
float bonus;
if(sales>=100000 && sales<1000000)
bonus = (float)sales/100;
else if (sales>=1000000)
bonus=((float)sales/100)*2;
else
bonus=0;
System.out.println(bonus);
}
}
we need to type cast atleast one of the integer from X/Y form to get result in float.As you can see in expression
bonus = (float)sales/100;
18.
CheckingAccount account=new CheckingAccount();
account veriable is stored in the stack area and it will refer to the heap where memory is given by using new operator.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.