Computer Science, asked by bhan61, 1 year ago



Question: Tiktok v2

You have recently seen a motivational sports movie and want to start exercising regularly. Your coach tells you that it is important to get up early in the morning to exercise. She sets up a schedule for you:

On weekdays (Monday - Friday), you have to get up at 5:00. On weekends (Saturday & Sunday), you can wake up at 6:00. However, if you are on vacation, then you can get up at 7:00 on weekdays and 9:00 on weekends.

Write a program to print the time you should get up.

Input Format

The first line contains n - the number of inputs.
Following that are n lines, each containing an integer and a boolean value.

The integer tells you the day it is (1-Sunday, 2-Monday, 3-Tuesday, 4-Wednesday, 5-Thursday, 6-Friday, 7-Saturday). The boolean is true if you are on vacation and false if you’re not on vacation.

You have to print the time you should get up.

Use the System.out.println() statement for printing.

Example Input:
1 false
5 false
1 true
Output:
6:00
5:00
9:00


bhan61: can anyone give me the answer

Answers

Answered by nitish8089
8
complete code....
import java.util.Scanner;
public class Program
{
public static void met(int days, boolean vacation){
if(vacation){
if(days>=2&&days<=6){
System.out.println("7:00");
}
else{
System.out.println("9:00");
}
}
else {
if(days>=2&&days<=6){
System.out.println("5:00");
}
else{
System.out.println("6:00");
}
}
}
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int days=sc.nextInt();
boolean vacation=sc.nextBoolean();
Program.met(days, vacation);
}
}

nitish8089: [email protected]
bhan61: i sent u a mail
bhan61: once please check it
bhan61: if the code is wrong please correct it and send me
bhan61: sorry to disturb you
nitish8089: OK... I CHECK IT
bhan61: my mail id is [email protected]
bhan61: tqqq
nitish8089: sent you an email .. check it... would you understand.. or now this time run out or not :D
bhan61: thanks a lot
Similar questions