Java - Nested If statements | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Java - Nested If statements

I don’t know what I’m doing wrong. The prompt says to return “Gift Card” after multiple inputs. import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner read = new Scanner(System.in); int purchases = read.nextInt(); //complete the code if(purchases > 15000) { if(purchases > 30000) { System.out.println("Gift card"); } else { System.out.println("Gift card"); } } } }

2nd Dec 2021, 4:15 PM
Ross Cohen
4 Answers
0
In any case, do you need Gift Card? Check your conditions again... >30000 is also >15000 . I think it asking in-between?
2nd Dec 2021, 4:34 PM
Jayakrishna 🇮🇳
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner read = new Scanner(System.in); int purchases = read.nextInt(); if(purchases > 15000){ System.out.println("Gift card"); //complete the code if (purchases > 30000) System.out.println("Gift card"); } } }
19th Feb 2022, 8:30 AM
Salman
Salman - avatar
0
if(purchases > 15000 ){ System.out.println("Gift card"); if(purchases > 30000){ System.out.println("Gift card"); } }
20th Feb 2023, 3:32 PM
Andrei
- 1
I ran out of space but the goal is to print Gift Card if the input is > 15000 and > 30000 but I can’t seem to get it to pass for > 30000
2nd Dec 2021, 4:29 PM
Ross Cohen