0

Java error

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int math = scanner.nextInt(); int history = scanner.nextInt(); int geometry = scanner.nextInt(); int vse=math+history+geometry; int chas = vse/60,min=vse%60; System.out.println(chas,min); //ваш код } }

17th Feb 2022, 8:29 PM
Антипов Никита Вячеславович
Антипов Никита Вячеславович - avatar
12 odpowiedzi
+ 1
println() takes 1 parameter, aside from that the task description asks us to print in 2 lines https://www.geeksforgeeks.org/system-out-println-in-java/ If you wanted to print it in 1 line, you would need to concatenate the outputs
17th Feb 2022, 8:51 PM
Lisa
Lisa - avatar
+ 1
It works because you concatenate the values to 1 string
17th Feb 2022, 8:52 PM
Lisa
Lisa - avatar
0
Output chas and min in separate lines using separate System.out.println()
17th Feb 2022, 8:46 PM
Lisa
Lisa - avatar
0
I got it. But why can't it be written in one line?
17th Feb 2022, 8:47 PM
Антипов Никита Вячеславович
Антипов Никита Вячеславович - avatar
0
System.out.println(chas+""+min); Why does it work?
17th Feb 2022, 8:51 PM
Антипов Никита Вячеславович
Антипов Никита Вячеславович - avatar
0
Which operator takes two values?
17th Feb 2022, 8:52 PM
Антипов Никита Вячеславович
Антипов Никита Вячеславович - avatar
0
What do you mean by which operator takes 2 values? You want to print both values, don't you?
17th Feb 2022, 8:54 PM
Lisa
Lisa - avatar
0
I want to enumerate variables with ", " and output them. Is it possible?
17th Feb 2022, 8:57 PM
Антипов Никита Вячеславович
Антипов Никита Вячеславович - avatar
0
You could use string formating and printf System.out.printf("%d\n%d", 33,123);
17th Feb 2022, 9:06 PM
Lisa
Lisa - avatar
0
What is printf responsible for? How is it different from println?
17th Feb 2022, 9:11 PM
Антипов Никита Вячеславович
Антипов Никита Вячеславович - avatar
17th Feb 2022, 9:19 PM
Lisa
Lisa - avatar
0
thanks for the answer
18th Feb 2022, 2:42 PM
Антипов Никита Вячеславович
Антипов Никита Вячеславович - avatar