Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedI 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();

image text in transcribed

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

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

Step: 3

blur-text-image

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

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

More Books

Students also viewed these Databases questions

Question

Discuss the states of accounting

Answered: 1 week ago

Question

What is DDL?

Answered: 1 week ago