+ 1
FOR LOOP IS NOT WORKING
import java.util.Scanner; class Hello{ public static void main (String[] args) { Scanner getage = new Scanner(System.in); System.out.println("Enter your age: ") ; int intgetage = getage.nextInt(); int x= 2018; int y = x - intgetage; for(int i = y; i > x; - - x){ System.out.println(i); } } }
4 Antworten
+ 5
ifraz I Hello, 😊
I do not see the purpose to keep your question in the Q/A section if you answered it yourself!
In the future, use Code playground to practice, if you can not solve the problem, then ask!👍
Use the search bar!
https://www.sololearn.com/post/10362/?ref=app
Please, read our guidelines:
https://www.sololearn.com/discuss/1316935/?ref=app
An useful code for any new user here!;)
https://code.sololearn.com/WvG0MJq2dQ6y/
+ 2
Got it. Thanks
import java.util.Scanner;
class Hello{
public static void main (String[] args) {
Scanner getage = new Scanner(System.in);
System.out.println("Enter your age: ") ;
int z = getage.nextInt();
int y = 2018 - z;
for(int i = 2018; i >= y; --i){
System.out.println(i);
}
}
}
+ 2
Bennett Post
Thanks for the response
0
Tashi N
Sorry,
Kept on trying, in the class and my lecturer also couldn't get it right. Thats y put it here.
But meanwhile, i changed it and it worked.
Anyway sorry.