0

Can anyone help me with this code, it is throwing input mismatch error.

import java.util.Scanner; public class Program { public static void main(String[] args) { int popsicles,siblings; Scanner Myvar = new Scanner(System.in); System.out.println("Enter the no. of Popsicles"); popsicles = Myvar.nextInt(); System.out.println("Enter the no. of siblings"); siblings = Myvar.nextInt(); if(popsicles> siblings || popsicles%siblings!=0){ System.out.println("Eat them yourself"); } else{ System.out.println("Give Away"); } // System.out.println(popsicles); } }

15th May 2022, 7:20 AM
Kishan Khanna
Kishan Khanna - avatar
2 Réponses
+ 3
Enter two integers as input, it should work just fine. On a different note, the first condition is supposed to be popsicles < siblings 😌
15th May 2022, 9:21 AM
Shamima Yasmin
Shamima Yasmin - avatar
+ 1
Thank you Shamima Yasmin 😊
15th May 2022, 9:24 AM
Kishan Khanna
Kishan Khanna - avatar