Question: I keep on getting a error code when doing this problem. This is the code that I have been using: if (dollarAmount >= 7) {

I keep on getting a error code when doing this problem. ThisI keep on getting a error code when doing this problem. This is the code that I have been using:

if (dollarAmount >= 7) {

System.out.print("Buy a keychain.");

}

if (dollarAmount > 19) {

System.out.print("Buy new shoes.");

}

if (dollarAmount

System.out.print("Save money.");

}

System.out.println();

is the code that I have been using: if (dollarAmount >= 7)

Please help!

Given integer dollarAmount, write multiple if statements: - If dollarAmount is greater than 7, output "Buy a keychain." - If dollarAmount is greater than or equal to 19, output "Buy new shoes." - If dollarAmount is less than or equal to 1, output "Save money." End with a newline. Ex: If the input is 22 , then the output is: Buy a keychain. Buy new shoes. \begin{tabular}{l|l} 1 & import java.util.Scanner; \\ 2 & Solic class RemainingAllowance \{ \\ 3 & public \\ 4 & public static void main (String[] args) \{ \\ 5 & Scanner scnr = new Scanner(System.in); \\ 6 & int dollarAmount; \\ 7 & \\ 8 & dollarAmount = scnr.nextInt(); \\ 9 & \\ 10 & \\ 11 & \} \\ 12 & \end{tabular} Output is nearly correct, but whitespace differs. See highlights below. Input Your output Expected output 4: Compare output 1 Input Your output Expected output This test case should produce no output 5: Compare output Input Your output 6: Compare output Input 7 Your output Expected output This test case should produce no output 7: Compare output Output differs. See highlights below. Input Your output Expected output

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!