+ 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

15th Oct 2022, 4:00 PM
jessica bencivenga
jessica bencivenga - avatar
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
15th Oct 2022, 4:09 PM
Prashanth Kumar
Prashanth Kumar - avatar
+ 5
Better send your attempt . So that we can guide you :)
15th Oct 2022, 4:01 PM
Prashanth Kumar
Prashanth Kumar - avatar
+ 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) ; } }
15th Oct 2022, 4:03 PM
jessica bencivenga
jessica bencivenga - avatar
+ 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) ; } }
15th Oct 2022, 5:49 PM
jessica bencivenga
jessica bencivenga - avatar
+ 2
Ok thank you that gives me an idea of where I went wrong thank you hopefully I can get it from there
15th Oct 2022, 5:32 PM
jessica bencivenga
jessica bencivenga - avatar
+ 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) ; } }
15th Oct 2022, 5:41 PM
jessica bencivenga
jessica bencivenga - avatar
+ 2
Oh now I see it lol
15th Oct 2022, 5:41 PM
jessica bencivenga
jessica bencivenga - avatar
+ 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 !
15th Oct 2022, 5:55 PM
jessica bencivenga
jessica bencivenga - avatar
+ 1
I did eventually get it and it was something simple lol 😆
16th Oct 2022, 8:01 PM
jessica bencivenga
jessica bencivenga - avatar
+ 1
Yes
17th Oct 2022, 3:53 AM
Johanes Antonius
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); } }
16th Oct 2022, 2:03 PM
R A
R A - avatar
- 2
Yeah its simple :D
16th Oct 2022, 8:27 PM
R A
R A - avatar