So I'm supposed to create a program in Javascript that gives you a menu with 4 options, the first would be to give you all even numbers between two user imput numbers, the second should give you all odd numbers between two user imput numbers, the third option should create a random number between two user imput numbers and ask for the user to guess which is it, wich would make the fourth option the exit.
so far my code looks like this.
`import java.util.Scanner;
public class Numbrz{ public static void main(String[] args) {
int seleccion=0;
Scanner sc = new Scanner(System.in);
while (seleccion !=4){
System.out.println ("Menu");
System.out.println ("1.- Even numbers between N1 and N2");
System.out.println ("2.- Odd numbers betwenn N1 y N2");
System.out.println ("3.- Random");
System.out.println ("4.- Exit");
seleccion = sc.nextInt();
}
if (seleccion == 1){
System.out.println ("First number")
N1 = sc.nextInt();
System.out.println ("Last Number")
N2 = sc.nextInt();
if (N1<N2){
}
}
else if (seleccion == 2){
System.out.println ("First ")
Num1 = sc.nextInt();
System.out.println ("Last")
Num2 = sc.nextInt();
}
else if (seleccion == 3) {
System.out.println ("First number")
No1 = sc.nextInt();
System.out.println ("Last Number")
No2 = sc.nextInt();
var number=Math.floor((Math.random() * No2) + No1);
var prediction = prompt("I'm thinking of a number between "+No1+" and "+No2+" ,What is it?"); // the user's prediction
prediction = parseInt(prediction);
var exitVariable = true;
System.out.println (number);
}
`
it's important to say it is not complete, I'd like to know if I'm doing it right or not, and what to do to make the porgram work better.
Aucun commentaire:
Enregistrer un commentaire