Basic Of Java
S1P1-WELCOME MESSAGE
Welcome Message
"Pine Tree" is a recently launched startup Event Management company. The company gained a good reputation within a short span because of its highly reliable service delivery.
Nikhil, the founder of this company wished to take the company’s services to the next step and decided to design an Event Management System that would let its Customers plan and host events seamlessly via an online platform. As a part of this requirement, Nikhil wanted to write a piece of code for his company’s Amphi Event Management System that will welcome all the Customers who are using it. Help Nikhil on the task.
Output Format:
Output should display "Welcome to Amphi Event Management System".
Refer sample output for formatting specifications.
Sample Output:
Welcome to Amphi Event Management System
Nikhil, the founder of this company wished to take the company’s services to the next step and decided to design an Event Management System that would let its Customers plan and host events seamlessly via an online platform. As a part of this requirement, Nikhil wanted to write a piece of code for his company’s Amphi Event Management System that will welcome all the Customers who are using it. Help Nikhil on the task.
Output Format:
Output should display "Welcome to Amphi Event Management System".
Refer sample output for formatting specifications.
Sample Output:
Welcome to Amphi Event Management System
Solution:
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
System.out.println("Welcome to Amphi Event Management System");
}
}
S1P2-CUSTOMIZED WELCOME MESSAGE
Customized Welcome Message
Nikhil, the founder of “Pine Tree” company wished to design an Event Management System that would let its Customers plan and host events seamlessly via an online platform.
As a part of this requirement, Nikhil wanted to write a piece of code for his company’s Amphi Event Management System that will display customized welcome messages by taking Customers’ name as input. Help Nikhil on the task.
Input Format:
First line of the input is a string that corresponds to a Customer’s name. Assume that the maximum length of the string is 50.
Output Format:
Output should display the welcome message along with the Customer’s name.
Refer sample input and output for formatting specifications.
[All text in bold corresponds to input and rest corresponds to output.]
Sample Input and Output:
Enter your name
Beena
Hello Beena ! Welcome to Amphi Event Management System
As a part of this requirement, Nikhil wanted to write a piece of code for his company’s Amphi Event Management System that will display customized welcome messages by taking Customers’ name as input. Help Nikhil on the task.
Input Format:
First line of the input is a string that corresponds to a Customer’s name. Assume that the maximum length of the string is 50.
Output Format:
Output should display the welcome message along with the Customer’s name.
Refer sample input and output for formatting specifications.
[All text in bold corresponds to input and rest corresponds to output.]
Sample Input and Output:
Enter your name
Beena
Hello Beena ! Welcome to Amphi Event Management System
Solution:
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
String name;
System.out.println("Enter your name");
name=sc.next();
System.out.println("Hello "+name+" ! Welcome to Amphi Event Management System");
}
}
S1P4-EVENT DETAILS
Event Details
Be it a last minute get together, a birthday party or corporate events, the "Pine Tree" Event Management Company helps you plan and execute it better and faster. Nikhil, the founder of the company wanted the Amphi Event Management System to get and display the event details from his Customers for every new order of the Company.
Write a program that will get the input of the event details like name of the event, type of the event, number of people expected, a string value (Y/N) telling whether the event is going to be a paid entry and the projected expenses (in lakhs) for the event. The program should then display the input values as a formatted output.
Input Format:
First input is a string that corresponds to the name of the event. Assume the maximum length of the string as 50.
Second input is a string that corresponds to the type of the event. Assume the maximum length of the string as 50.
Third input is an integer that corresponds to the number of people expected for the event.
Fourth input is a character that corresponds to Y/N telling whether the event is going to be a paid entry or not.
Fifth input is a double value that corresponds to the projected expenses (in lakhs) for the event.
Output Format:
Output should display the event details as given in the sample output.
All double values need to be displayed correct to 1 decimal place
Refer sample input and output for formatting specifications.
[All text in bold corresponds to input and rest corresponds to output.]
Sample Input and Output:
Enter the name of the event
Food Fest 2017
Enter the type of the event
Public
Enter the number of people expected
5000
Is it a paid entry? (Type Y or N)
N
Enter the projected expenses (in lakhs) for this event
5.7
Event Name : Food Fest 2017
Event Type : Public
Expected Count : 5000
Paid Entry : N
Projected Expense : 5.7L
Write a program that will get the input of the event details like name of the event, type of the event, number of people expected, a string value (Y/N) telling whether the event is going to be a paid entry and the projected expenses (in lakhs) for the event. The program should then display the input values as a formatted output.
Input Format:
First input is a string that corresponds to the name of the event. Assume the maximum length of the string as 50.
Second input is a string that corresponds to the type of the event. Assume the maximum length of the string as 50.
Third input is an integer that corresponds to the number of people expected for the event.
Fourth input is a character that corresponds to Y/N telling whether the event is going to be a paid entry or not.
Fifth input is a double value that corresponds to the projected expenses (in lakhs) for the event.
Output Format:
Output should display the event details as given in the sample output.
All double values need to be displayed correct to 1 decimal place
Refer sample input and output for formatting specifications.
[All text in bold corresponds to input and rest corresponds to output.]
Sample Input and Output:
Enter the name of the event
Food Fest 2017
Enter the type of the event
Public
Enter the number of people expected
5000
Is it a paid entry? (Type Y or N)
N
Enter the projected expenses (in lakhs) for this event
5.7
Event Name : Food Fest 2017
Event Type : Public
Expected Count : 5000
Paid Entry : N
Projected Expense : 5.7L
Solution:
import java.util.Scanner;
import java.text.DecimalFormat;
public class Main
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
DecimalFormat df=new DecimalFormat("#.#");
String eventName,eventType;
long num;
String paid;
double expense;
System.out.println("Enter the name of the event");
eventName=sc.nextLine();
System.out.println("Enter the type of the event");
eventType=sc.nextLine();
System.out.println("Enter the number of people expected");
num=sc.nextLong();
System.out.println("Is it a paid entry? (Type Y or N)");
paid=sc.next();
System.out.println("Enter the projected expenses (in lakhs) for this event");
expense=sc.nextDouble();
System.out.println("Event Name : "+eventName);
System.out.println("Event Type : "+eventType);
System.out.println("Expected Count : "+num);
System.out.println("Paid Entry : "+paid);
System.out.printf("Projected Expense : %.1f L",expense);
}
}
S1P5-TOTAL EXPENSES FOR THE EVENT
Total Expenses for the Event
The prime functionality of an Event Management System is budgeting. An Event Management System should estimate the total expenses incurred by an event and the percentage rate of each of the expenses involved in planning and executing an event. Nikhil, the founder of "Pine Tree" wanted to include this functionality in his company’s Amphi Event Management System and requested your help in writing a program for the same.The program should get the branding expenses, travel expenses, food expenses and logistics expenses as input from the user and calculate the total expenses for an event and the percentage rate of each of these expenses.
Input Format:
First input is a int value that corresponds to the branding expenses.
Second input is a int value that corresponds to the travel expenses.
Third input is a int value that corresponds to the food expenses.
Fourth input is a int value that corresponds to the logistics expenses.
Output Format:
First line of the output should display the int value that corresponds to the total expenses for the Event.
Next four lines should display the percentage rate of each of the expenses.
Refer sample input and output for formatting specifications.
[All text in bold corresponds to input and rest corresponds to output.]
Sample Input and Output:
Enter branding expenses
20000
Enter travel expenses
40000
Enter food expenses
15000
Enter logistics expenses
25000
Total expenses : Rs.100000.00
Branding expenses percentage : 20.00%
Travel expenses percentage : 40.00%
Food expenses percentage : 15.00%
Logistics expenses percentage : 25.00%
Solution:
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
{
Double a,b,c,d,total;
System.out.println("Enter branding expenses");
a=sc.nextDouble();
System.out.println("Enter travel expenses");
b=sc.nextDouble();
System.out.println("Enter food expenses");
c=sc.nextDouble();
System.out.println("Enter logistics expenses");
d=sc.nextDouble();
total=a+b+c+d;
System.out.printf("Total expenses : Rs.%.2f",total);
System.out.println();
System.out.printf("Branding expenses percentage : %.2f",(a*100)/total);
System.out.println("%");
System.out.printf("Travel expenses percentage : %.2f",(b*100)/total);
System.out.println("%");
System.out.printf("Food expenses percentage : %.2f",(c*100)/total);
System.out.println("%");
System.out.printf("Logistics expenses percentage : %.2f",(d*100)/total);
System.out.println("%");
}
}
}
S1P11-BIRTHDAY CHALLENGE
Birthday Challenge
Louis was celebrating his 10th Birthday and his parents wished to make his birthday more special by throwing a surprise bash, inviting all their friends, relatives and neighbors. The little mathematics geek Louis has another surprise waiting for him when he had to cut his favorite Choco vanilla cake. The cake is a rectangular cake and it consists of m×n (1≤m, n≤1000) squares. His friends now called him out for a challenge.
The challenge is that, Louis has to break the cake up into 1×1 pieces (individual squares) and find what is the minimum number of times that he breaks the choco vanilla cake, or pieces therefore, in order to achieve this?
Note that he cannot stack pieces of the cake and break them, because the choco vanilla cake is thick. As an example, a 2×2 cake requires 3 breaks. First he can break it in half, then break each of the halves in half. He cannot break it in half, stack the two 1×2 pieces, and then use only one more break to achieve his goal.
Input Format:
First line of the input consists of an integer, the dimensions m of the choco vanilla cake.
Second line of the input consists of an integer, the dimensions n of the choco vanilla cake.
Output Format:
Output the minimum number of times that he breaks the choco vanilla cake
Refer sample input and output for formatting specifications.
[All text in bold corresponds to input and rest corresponds to output.]
Sample Input and Output 1:
Enter m
1
Enter n
2
Minimum number of times is 1
Sample Input and Output 2:
Enter m
2
Enter n
2
Minimum number of times is 3
The challenge is that, Louis has to break the cake up into 1×1 pieces (individual squares) and find what is the minimum number of times that he breaks the choco vanilla cake, or pieces therefore, in order to achieve this?
Note that he cannot stack pieces of the cake and break them, because the choco vanilla cake is thick. As an example, a 2×2 cake requires 3 breaks. First he can break it in half, then break each of the halves in half. He cannot break it in half, stack the two 1×2 pieces, and then use only one more break to achieve his goal.
Input Format:
First line of the input consists of an integer, the dimensions m of the choco vanilla cake.
Second line of the input consists of an integer, the dimensions n of the choco vanilla cake.
Output Format:
Output the minimum number of times that he breaks the choco vanilla cake
Refer sample input and output for formatting specifications.
[All text in bold corresponds to input and rest corresponds to output.]
Sample Input and Output 1:
Enter m
1
Enter n
2
Minimum number of times is 1
Sample Input and Output 2:
Enter m
2
Enter n
2
Minimum number of times is 3
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int m,n;
System.out.println("Enter m");
m=sc.nextInt();
System.out.println("Enter n");
n=sc.nextInt();
int res=(m-1)+m*(n-1);
System.out.println("Minimum number of times is "+res);
}
}
S1P7-TICKETS SOLD FOR CHARITY EVENT
Tickets sold for Charity Event
HelpIndia, a famous NGO has been selective in identifying events to raise funds for charity. Suzanne is a volunteer from the NGO who was selling tickets to the public for the charity event. She sold 'X' more adult tickets than children tickets and she sold twice as many senior tickets as children tickets. Assume that an adult ticket costs $5, children ticket costs $2 and senior ticket costs $3.
Suzanne made 'Y' dollars from ticket sales. Find the number of adult tickets, children tickets, and senior tickets sold.
Input Format:
The first input is an integer value X that corresponds to the number of adult tickets more than children tickets.
The second input is an integer value Y that corresponds to the money in dollars made by Suzanne from ticket sales.
Output Format:
The first line of the output should display the number of children tickets sold.
The second line of the output should display the number of adult tickets sold.
The third line of the output should display the number of senior tickets sold.
Refer sample input and output for formatting specifications.
[All text in bold corresponds to input and rest corresponds to output.]
Sample Input and Output :
Enter the value of X
10
Enter the value of Y
700
Number of children tickets sold : 50
Number of adult tickets sold : 60
Number of senior tickets sold : 100
Suzanne made 'Y' dollars from ticket sales. Find the number of adult tickets, children tickets, and senior tickets sold.
Input Format:
The first input is an integer value X that corresponds to the number of adult tickets more than children tickets.
The second input is an integer value Y that corresponds to the money in dollars made by Suzanne from ticket sales.
Output Format:
The first line of the output should display the number of children tickets sold.
The second line of the output should display the number of adult tickets sold.
The third line of the output should display the number of senior tickets sold.
Refer sample input and output for formatting specifications.
[All text in bold corresponds to input and rest corresponds to output.]
Sample Input and Output :
Enter the value of X
10
Enter the value of Y
700
Number of children tickets sold : 50
Number of adult tickets sold : 60
Number of senior tickets sold : 100
Comments
Post a Comment