+ 3
First quiz java
Time converter I can't seem to get this one right can someone please send me the solution for the first quiz in java so I can compare and see where I went wrong
12 Answers
+ 5
you use type only while declarating a new variable .
and to store anything in variable you can do
variableName= some value ;
so
int days * int hours = int hrsresult;
is wrong approach ..
instead you should do it like this
int hrsresult = days * hours;
here we have declared hrsresult so we use type in as prefix for it .. and then assign it to days*hours .
note as days and hours are already declared so you dont need to use int prefix (type) before it .
Hope you got a hint
+ 5
Better send your attempt .
So that we can guide you :)
+ 3
This is what I got so far
import java.util.Scanner;
public class Program {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int days = scanner.nextInt();
int hours = 24, mins = 60, sec =60;
int days * int hours = int hrsresult;
int hrsresult * int mins = int minResult;
int minResult * int sec = int totaltsec;
System.out.printint(totaltsec) ;
}
}
+ 3
Lol so I thought I had it but still stuck my goodness I've never gotten this stuck befor
import java.util.Scanner;
public class Program {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int days = scanner.nextInt();
int hours = 24, mins = 60, sec =60;
int hrsresult = (days * hours) ;
int minResult = (hrsresult * mins);
int totalsec = (minsresults * sec);
System.out.println(totalsec) ;
}
}
+ 2
Ok thank you that gives me an idea of where I went wrong thank you hopefully I can get it from there
+ 2
So I'm still having trouble here's what I re wrote
import java.util.Scanner;
public class Program {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int days = scanner.nextInt();
int hours = 24, mins = 60, sec =60;
int hrsresult = (days * hours) ;
int minResult = (hours * sec);
int totalsec = (mins * sec);
System.out.printint(totaltsec) ;
}
}
+ 2
Oh now I see it lol
+ 2
I'm just gonna take a break and come back to it I'm sure it's something simple I'm missing and been rushing and frustrated so I'm never gonna fix it in that state of mind but if anyone has the code for this and will show me so I can compare to my answers that would be great or just let me know where I'm messing up that be so awesome and thank you for everyone's help so far I really appreciate it !
+ 1
I did eventually get it and it was something simple lol đ
+ 1
Yes
0
import java.util.Scanner;
public class Program {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int days = scanner.nextInt();
//your code goes here
int hours = days * 24;
int minutes = hours * 60;
int seconds = minutes * 60;
System.out.println(seconds);
}
}
- 2
Yeah its simple :D