import java.util.Scanner;
public class AroundTheClock
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int departureTime =
input.nextInt();
int travelTime =
input.nextInt();
int arrivalTime;
departureTime
=12;
departureTime =
0;
arrivalTime = (int) (departureTime + travelTime);
(arrivalTime = (arrivalTime >=12));
if
(arrivalTime = arrivalTime %12)
{
System.out.println(arrivalTime);
}
else
{
System.out.println("Enter Numbers Only");
}
}
}
AroundTheClock.java:19: error: not a statement
(arrivalTime = (arrivalTime >=12));
^
1 error
import java.util.Scanner; public class AroundTheClock { public static void main(String[] args) { Scanner input = new Scanner(System.in); int departureTime = input.nextInt(); int travelTime = input.nextInt(); int arrivalTime; departureTime = 12; departureTime = 0; arrivalTime = (int) (departureTime + travelTime); // arrivalTime = (arrivalTime >= 12); // Note: arrivalTime >= 12 gives a value of either true or false. so, we can't store this value in an integer. like you were doing if (arrivalTime == arrivalTime % 12) { // = is not used in comparison, instead == is used to test for equality. System.out.println(arrivalTime); } else { System.out.println("Enter Numbers Only"); } } }
Get Answers For Free
Most questions answered within 1 hours.