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: java program

Ankit is going to preform today in Ignite, as he usually forgets his instruments so you need to check whether he will perform or not using a Java Program as he can understand JAVA only.

1.Check whether he is having his Guitar.

2.Check whether his guitar is having String.

3.Check whether he is having his Mic.

4.Check whether Harsh, his manager is available or not.



With guitar ?Guitar: He can only play?, With Mic "Mic: He can only Sing"

With guitar check his guitar is having Strings or not,

Without manager he won´t perform and if everything is fine then "He can Play and Sing" else

"No show today!"



Input specification:

Input should be Boolean values separated by space

input will be for Guitar , Mic ,Strings & manager

Sample Input:

true true true false

Sample Output:

No show today!

corejava x 352
programming x 168
Posted On : 2016-10-02 12:22:51.0
profile Aarti Kumar - anyforum.in Aarti Kumar
5900
up-rate
3
down-rate

Answers


Check this code and let me know conditions are satisfied or not.

import java.util.Scanner;
class Ankit
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
boolean G=in.nextBoolean();
boolean Mic=in.nextBoolean();
boolean Strs=in.nextBoolean();
boolean Mang=in.nextBoolean();
if ((G==true)&&(Mic==true)&&(Strs==true)&&(Mang==true))
{
System.out.println("He can Play and Sing!!");
}
else
{
System.out.println("No show today!");
}
}
}

Posted On : 2016-10-03 11:10:33
Satisfied : 1 Yes  2 No
profile Sudheer Kumar Javvadi - anyforum.in Sudheer Kumar Javvadi
0960
Reply This Thread
up-rate
2
down-rate
Comments
Hi,
You have written code only for 4th test case, You left these three cases

* With Guitar: He can only play?,
* With Mic "Mic: He can only Sing"

* With guitar check his guitar is having Strings or not,

3rd condition is if Guitar is true, then we have to check Strings should also be true and then only he can play. If only mic is true, rest are false, "then only he can sing".
profile Rishi Kumar - anyforum.in Rishi Kumar
523  1882  22437
Posted On :2016-10-06 19:01:10.0
Leave a Comment

import java.util.Scanner;
public class Band {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
boolean G=in.nextBoolean();
boolean Mic=in.nextBoolean();
boolean Strs=in.nextBoolean();
boolean Mang=in.nextBoolean();
if(Mang){
if(G && Strs){
if(Mic){
System.out.println("He can Play and Sing!!");
}else{
System.out.println("He can only play!!");
}
}else if(Mic){
System.out.println("He can only sing!!");
}
}else{
System.out.println("No show today!");
}
}
}

Posted On : 2016-10-06 19:18:50
Satisfied : 0 Yes  2 No
profile Rishi Kumar - anyforum.in Rishi Kumar
523188222437
Reply This Thread
up-rate
0
down-rate



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