0
Create a security system for age appropriate access to social media.
I need to make a program on the above topic. Please help someone. Age should be above 18 and I still have to input the code for the email which I can't seem to get. https://code.sololearn.com/cUbhQd8ExmoD/?ref=app
3 Respuestas
+ 1
What is your attempt so that we can help you debug?
+ 1
After Scanner class import, it works fine.
In code link, for emailaddress = name.nextLine() name is not scanner object, it must be keyboard like keyboard.nextLine() ;
but already have email input then you can use emailaddress= email. Else remove anyone of these two...
0
import java.util.Scanner;
public class HowOldAreYou {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
String name;
int age;
System.out.print("Hey, what's your name? ");
name = keyboard.next();
System.out.println();
System.out.print("Ok, " + name + ", how old are you? ");
age = keyboard.nextInt();
System.out.println();
if (age < 16) {
System.out.println("You can't Login in Facebook, " + name + ".");
}
if (age < 18) {
System.out.println("You can't Login in Instagram, " + name + ".");
}
if (age < 25) {
System.out.println("You can login, " + name + ".");
}
if (age >= 25) {
System.out.println("You can do anything that's legal, " + name + ".");
}
}
}