AF
HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.



corejava-programming: Answering Protocol in JAVA

You have an answering protocol when your mobile rings. 1. You never answer it when you are sleeping. 2. You answer it in the morning, only if your mother calls. 3. All other times you answer it. Write a Java program to decide whether you must answer the phone call or not. Input specification: 3 Boolean variables - isMom, isAsleep, isMorning Output specification: true if you answer, false if you do not answer. Sample input: false false false Sample output: true

corejava x 352
programming x 168
Posted On : 2016-10-11 11:38:08.0
profile Akash Prasad - anyforum.in Akash Prasad
2550
up-rate
5
down-rate

Answers


import java.util.Scanner;


public class PickCall {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
boolean isMom=input.nextBoolean();
boolean isAsleep=input.nextBoolean();
boolean isMorning=input.nextBoolean();
if(isAsleep){
System.out.println(false);
}else if(isMorning){
if(isMom)
System.out.println(true);
else
System.out.println(false);
}else{
System.out.println(true);
}
}
}

Posted On : 2016-10-12 23:25:49
Satisfied : 1 Yes  0 No
profile Rishi Kumar - anyforum.in Rishi Kumar
523188221961
Reply This Thread
up-rate
4
down-rate



Post Answer
Please Login First to Post Answer: Login login with facebook - anyforum.in