Java All Merge
Java All Merge
Java All Merge
AirVoice - Registration
Grade settings: Maximum grade: 100
Disable external file upload, paste and drop external content: Yes
Run: Yes Evaluate: Yes
Automatic grade: Yes Maximum execution time: 16 s
SmartBuy is a leading mobile shop in the town. After buying a product, the customer needs to
provide a few personal details for the invoice to be generated.
You being their software consultant have been approached to develop software to retrieve the
personal details of the customers, which will help them to generate the invoice faster.
String emailId
int age
Get the details as shown in the sample input and assign the value for its attributes using the
setters.
Display the details as shown in the sample output using the getters method.
Note:
In the Sample Input / Output provided, the highlighted text in bold corresponds to the input given
by the user and the rest of the text represents the output.
Ensure to provide the names for classes, attributes and methods as specified in the question.
Sample Input 1:
john
Enter the ContactNumber:
9874561230
32
Sample Output 1:
Name:john
ContactNumber:9874561230
EmailId:[email protected]
Age:32
Automatic evaluation[+]
Customer.java
1 public class Customer {
2 private String customerName;
3
4 private long contactNumber;
5
6 private String emailId;
7
8 private int age;
9
10 public String getCustomerName() {
11 return customerName;
12 }
13
14 public void setCustomerName(String customerName) {
15 this.customerName = customerName;
16 }
17
18 public long getContactNumber() {
19 return contactNumber;
20 }
21
22 public void setContactNumber(long contactNumber) {
23 this.contactNumber = contactNumber;
24 }
25
26 public String getEmailId() {
27 return emailId;
28 }
29
30 public void setEmailId(String emailId) {
31 this.emailId= emailId;
32 }
33
34 public int getAge() {
35 return age;
36 }
37
38 public void setAge(int age){
39 this.age = age;
40 }
41
42
43
44 }
Main.java
1 import java.util.Scanner;
2
3 public class Main {
4
5 public static void main (String[] args) {
6 Scanner sc=new Scanner(System.in);
7
8 //Fill the code
9 Customer c=new Customer();
10 System.out.println("Enter the Name:");
11 String name=(sc.nextLine());
12 System.out.println("Enter the ContactNumber:");
13 long no=sc.nextLong();
14 sc.nextLine();
15 System.out.println("Enter the EmailId:");
16 String mail=sc.nextLine();
17
18 System.out.println("Enter the Age:");
19 int age=sc.nextInt();
20 c.setCustomerName(name);
21 c.setContactNumber(no);
22 c.setEmailId(mail);
23 c.setAge(age);
24 System.out.println("Name:"+c.getCustomerName());
25 System.out.println("ContactNumber:"+c.getContactNumber());
26 System.out.println("EmailId:"+c.getEmailId());
27 System.out.println("Age:"+c.getAge());
28
29
30
31 }
32
33 }
2. Grade
Reviewed on Friday, 10 December 2021, 6:14 PM by Automatic grade
Grade 100 / 100
Assessment report
[+]Grading and Feedback
3. ZeeZee bank
Grade settings: Maximum grade: 100
Disable external file upload, paste and drop external content: Yes
Run: Yes Evaluate: Yes
Automatic grade: Yes Maximum execution time: 16 s
ZeeZee is a leading private sector bank. In the last Annual meeting, they decided to give their
customer a 24/7 banking facility. As an initiative, the bank outlined to develop a stand-alone
device that would offer deposit and withdrawal of money to the customers anytime.
You being their software consultant have been approached to develop software to implement the
functionality of deposit and withdrawal anytime.
As per this requirement, the customer should be able to deposit money into his account at any
time and the deposited amount should reflect in his account balance.
As per this requirement, the customer should be able to withdraw money from his account
anytime he wants. The amount to be withdrawn should be less than or equal to the balance in
the account. After the withdrawal, the account should reflect the balance amount
Component Specification: Account
In the Main class, Get the details as shown in the sample input.
Create an object for the Account class and invoke the deposit method to deposit the amount and
withdraw method to withdraw the amount from the account.
Note:
If the balance amount is insufficient then display the message as shown in the Sample Input /
Output.
In the Sample Input / Output provided, the highlighted text in bold corresponds to the input given
by the user and the rest of the text represents the output.
Ensure to provide the names for classes, attributes, and methods as specified in the question.
Sample Input/Output 1:
1234567890
15000
Enter the amount to be deposited:
1500
500
Sample Input/Output 2:
1234567890
15000
1500
18500
Insufficient balance
Automatic evaluation[+]
Main.java
1 import java.util.Scanner;
2 import java.text.DecimalFormat;
3
4 public class Main{
5
6 public static void main (String[] args) {
7 Scanner sc=new Scanner(System.in);
8 DecimalFormat decimalFormat=new DecimalFormat("0.00");
9 System.out.println("Enter the account number:");
10 long accountNumber= sc.nextLong();
11 System.out.println("Enter the available amount in the account:");
12 double balanceAmount= sc.nextDouble();
13 Account account=new Account(accountNumber,balanceAmount);
14 System.out.println("Enter the amount to be deposited:");
15 double depositAmount=sc.nextDouble();
16 account.deposit(depositAmount);
17 double availableBalance=account.getBalanceAmount();
18 System.out.println("Available balance is:"+decimalFormat.format(availableBalance));
19 System.out.println("Enter the amount to be withdrawn:");
20 double withdrawAmount= sc.nextDouble();
21 boolean isWithdrawn=account.withdraw(withdrawAmount);
22 availableBalance=account.getBalanceAmount();
23 if(!isWithdrawn){
24 System.out.println("Insufficient balance");
25 }
26 System.out.println("Available balance is:"+decimalFormat.format(availableBalance));
27
28 //Fill the code
29 }
30 }
Account.java
1
2 public class Account {
3 private long accountNumber;
4 private double balanceAmount;
5 public Account(long accountNumber,double balanceAmount){
6 this.accountNumber=accountNumber;
7 this.balanceAmount=balanceAmount;
8 }
9 public long getAccountNumber(){
10 return accountNumber;
11 }
12 public void setAccountNumber(long accountNumber){
13 this.accountNumber=accountNumber;
14 }
15 public double getBalanceAmount(){
16 return balanceAmount;
17 }
18 public void setBalanceAmount(double balanceAmount){
19 this.balanceAmount=balanceAmount;
20 }
21 public void deposit(double depositAmount){
22 balanceAmount+=depositAmount;
23 }
24 public boolean withdraw(double withdrawAmount){
25 if(withdrawAmount<=balanceAmount){
26 balanceAmount-=withdrawAmount;
27 return true;
28 }
29 return false;
30 }
31 }
Grade
Reviewed on Thursday, 27 May 2021, 3:28 AM by Automatic grade
Grade 100 / 100
Assessment report
[+]Grading and Feedback
3.Call Details
Grade settings: Maximum grade: 100
Disable external file upload, paste and drop external content: Yes
Run: Yes Evaluate: Yes
Automatic grade: Yes Maximum execution time: 16 s
AirCarrier is a leading mobile network provider. They maintain a record of all the calls made by
their postpaid customers.The details are stored in a particular format
[callId:calledNumber:noOfMinutes] .At the end of every month, the network provider wants to
extract the information from the file and populate it to the Call object for calculating the bill.
You being their software consultant have been approached to develop software to implement the
functionality of extracting the data from the given format.
float duration
This requirement is responsible for extracting the customer’s callId, calledNumber and duration
from the callDetails. After the extraction set the callId, calledNumber and duration to the call
object.
In the Main class, Get the details as shown in the sample input.
Create an object for the Call and invoke the parseData method to set the callId, calledNumber
and duration for each customer.
Invoke the corresponding getters to display the call details as shown in the Sample Output
Note:
In the Sample Input / Output provided, the highlighted text in bold corresponds to the input given
by the user and the rest of the text represents the output.
Ensure to provide the names for classes, attributes and methods as specified in the question.
Sample Input 1:
102:6547891230:2.15
Sample Output 1:
Call id:102
Called number:6547891230
Duration:2.15
============================================================
Automatic evaluation[+]
Main.java
1 import java.util.Scanner;
2
3 public class Main {
4
5 public static void main (String[] args) {
6 Scanner sc=new Scanner(System.in);
7 System.out.println("Enter the call details:");
8 String a=sc.nextLine();
9 Call obj=new Call();
10 obj.parseData(a);
11 System.out.println("Call id:"+obj.getCallId());
12 System.out.println("Called number:"+obj.getCalledNumber());
13 System.out.println("Duration:"+obj.getDuration());
14 //Fill the code
15
16 }
17 }
Call.java
1
2 public class Call {
3 private int callId;
4 private long calledNumber;
5 private float duration;
6 public Call(){
7 }
8 public int getCallId(){
9 return callId;
10 }
11 public long getCalledNumber(){
12 return calledNumber;
13 }
14 public float getDuration(){
15 return duration;
16 }
17 public void setCallId(int callId){
18 this.callId=callId;
19 }
20 public void setCalledNumber(long calledNumber){
21 this.calledNumber=calledNumber;
22 }
23 public void setDuration(float duration){
24 this.duration=duration;
25 }
26 public void parseData(String calld){
27 callId=Integer.parseInt(calld.split(":")[0]);
28 setCallId(callId);
29 calledNumber=Long.parseLong(calld.split(":")[1]);
30 setCalledNumber(calledNumber);
31 duration=Float.parseFloat(calld.split(":")[2]);
32 setDuration(duration);
33 }
34 }
Grade
Reviewed on Tuesday, 4 May 2021, 4:58 AM by Automatic grade
Grade 100 / 100
Assessment report
[+]Grading and Feedback
The pair is found by checking whether the product of the numbers is same as the product of the
reversed numbers. If it is same, then print "Correct pair found". If not print, "Correct pair not
found".
Note:
In the Sample Input / Output provided, the highlighted text in bold corresponds to the input given
by the user and the remaining text represents the output.
Hint: [13*62=31*26]
Sample Input 1:
13
62
Sample Output 1:
Sample Input 2:
10
56
Sample Output 2:
Automatic evaluation[+]
Main.java
1 import java.util.*;
2
3 public class Main{
4
5 public static void main (String[] args) {
6 Scanner sc=new Scanner(System.in);
7
8 int a=sc.nextInt();
9 int b=sc.nextInt();
10 if(a>99||a<10||b>99||b<10){
11 System.out.println("No");
12
13 }
14 Main obj=new Main();
15 int ra=obj.rvs(a);
16 int rb=obj.rvs(b);
17 if(a*b==ra*rb){
18 System.out.println(a+" and "+b+" are correct pair");
19 }
20 else{
21 System.out.println(a+" and "+b+" are not correct pair");
22 }
23 }
24 int rvs(int num){
25 int r,rnum=0;
26 while(num>0)
27 {
28 r=num%10;
29 rnum=rnum*10+r;
30 num/=10;
31 }
32 return(rnum);
33 }
34 }
35
36
37
38
39
40
Grade
Reviewed on Thursday, 27 May 2021, 3:38 AM by Automatic grade
Grade 100 / 100
Assessment report
TEST CASE PASSED
[+]Grading and Feedback
----------------------------------End---------------------------------------------------
Group-2
You being their software consultant have been approached by them to develop an application
which can be used for managing their business. You need to implement a java program using
thread to find out the count of members in each membership category. Membership details
should be obtained from the user in the console.
Count the number of members available in the memberList based on the membership category
to be searched and set the value to count attribute.
Create a class called Main with the main method and get the inputs like number of
members, member details, number of times Membership category needs to be
searched and Membership category to be searched from the user.
Parse the member details and set the values for all attributes in Member class
using constructor.
Invoke the ZEEShop thread class for each memberCategory and count the number of members
in that category and display the count as shown in the sample input and output.
Assumption: The memberCategory is case –sensitive and will be of only three values –
Platinum or Gold or Silver.
Note:
In the Sample Input / Output provided, the highlighted text in bold corresponds to the input given
by the user and the remaining text represents the output.
102:Sam:Gold
103:John:Silver
104:Rose:Platinum
105:Tint:Silver
Gold
Silver
Platinum
Gold
Gold:2
Silver:2
Platinum:1
Gold:2
Automatic evaluation[+]
Member.java
1
2 public class Member {
3
4 private String memberId;
5 private String memberName;
6 private String category;
7
8 public String getMemberId() {
9 return memberId;
10 }
11 public void setMemberId(String memberId) {
12 this.memberId = memberId;
13 }
14 public String getMemberName() {
15 return memberName;
16 }
17 public void setMemberName(String memberName) {
18 this.memberName = memberName;
19 }
20 public String getCategory() {
21 return category;
22 }
23 public void setCategory(String category) {
24 this.category = category;
25 }
26
27 public Member(String memberId, String memberName, String category) {
28 super();
29 this.memberId = memberId;
30 this.memberName = memberName;
31 this.category = category;
32 }
33
34
35 }
Main.java
1 import java.util.*;
2 public class Main {
3
4 public static void main(String args[]){
5 // Fill the code here
6 List<Member> memberList = new ArrayList<Member>();
7 Scanner scan = new Scanner(System.in);
8 System.out.println("Enter the no of Members");
9 int memberCount = scan.nextInt();
10 String tempIp;
11 while(memberCount>0){
12 System.out.println("Enter the member details");
13 tempIp = scan.next();
14 String tempArr[] = tempIp.split(":");
15 memberList.add(new Member(tempArr[0],tempArr[1],tempArr[2]));
16 memberCount--;
17 }
18 System.out.println("Enter the number of times Membership category needs to be searched");
19 int noOfTimes = scan.nextInt();
20 String[] tempArr = new String[noOfTimes];
21 for(int index=0;index<noOfTimes;index++){
22 System.out.println("Enter the category");
23 tempArr[index] = scan.next();
24 }
25 int countArr[] = new int [noOfTimes];
26 for(int i=0; i<noOfTimes;i++){
27 ZEEShop thread = new ZEEShop(tempArr[i],memberList);
28 thread.run();
29 /*try{
30 thread.join();
31 }catch(InterruptedException e){
32
33 }*/
34 countArr[i] = thread.getCount();
35 }
36 for(int i=0;i<noOfTimes;i++){
37 System.out.println(tempArr[i]+ ":"+countArr[i]);
38 }
39 scan.close();
40 /*List<ZEEShop> zList = new ArrayList<ZEEShop>()
41 for(int i = 0;i<count;i++){
42 ZEEShop zs = new ZEEShop(category , memList);
43 zList.add(zs);
44 }
45 for(ZEEShop z: zeelist){
46 z.start();
47 try{
48 z.join();
49 }catch(Exception e){
50 e.printStackTrace();
51 }
52 }*/
53 }
54 }
55
ZEEShop.java
1 import java.util.*;
2 public class ZEEShop extends Thread {
3 // Fill the code here
4 private String memberCategory;
5 private int count;
6 private List<Member> memberList;
7 public ZEEShop(String memberCategory, List memberList){
8 super();
9 this.memberCategory = memberCategory;
10 this.memberList = memberList;
11 }
12 public int getCount(){
13 return count;
14 }
15 public String getMemberCategory(){
16 return memberCategory;
17 }
18 public List<Member> getMemberList(){
19 return memberList;
20 }
21 public void setMemberCategory(String memberCategory){
22 this.memberCategory = memberCategory;
23 }
24 public void setMemberList(List<Member> memberList){
25 this.memberList = memberList;
26 }
27 public void setCount(int count){
28 this.count = count;
29 }
30 public void run(){
31
32 synchronized(this)
33 {
34 for(Member m : memberList){
35 if(m.getCategory().equals(memberCategory))
36 count++;
37 }
38
39 }
40 }
41 }
42
Grade
Reviewed on Friday, 7 January 2022, 7:25 PM by Automatic grade
Grade 100 / 100
Assessment report
[+]Grading and Feedback
2. Grade Calculation
Grade settings: Maximum grade: 100
Disable external file upload, paste and drop external content: Yes
Run: Yes Evaluate: Yes
Automatic grade: Yes Maximum execution time: 32 s
Grade Calculation
Rita is working as a science teacher in an International school. She is the Class Teacher of class
V and was busy in calculating the grade for each student in her class, based on his/her total
marks obtained in SA1 assessment.
Since she found it very difficult to calculate the grade, she approached you to develop an
application which can be used for completing her task faster. You need to implement a java
program using thread to calculate the grade for each student. Student details should be obtained
from the user in the console.
Calculate the grade based on total marks (sum of all marks) as shown below obtained by each
student and set the same in result attribute for respective student.
Assumption: Each student will have only five subjects and marks of each subject will be greater
than or equal to 0 and lesser than or equal to 100. Hence the maximum Total marks obtained by
each student will be 500. And the minimum Total marks obtained by each student will be 0.
Create a class called Main with the main method and get the inputs like number of
threads and Student details from the user.
Parse the student details and set the values of studName and marks attributes
in GradeCalculator thread class using constructor.
Invoke the GradeCalculator thread class to calculate the grade based on total marks and set the
same to result attribute.
Display the Student name and Grade obtained by each student as shown in the sample input
and output.
Note:
In the Sample Input / Output provided, the highlighted text in bold corresponds to the input given
by the user and the remaining text represents the output.
Jeba:100:80:90:40:55
Adam:90:80:90:50:75
Rohit:99:99:99:99:99
Jeba:B
David:E
Adam:B
Rohit:A
Automatic evaluation[+]
Main.java
1 import java.util.Scanner;
2 import java.io.BufferedReader;
3 import java.io.InputStreamReader;
4 public class Main {
5 public static void main(String[] args) throws Exception {
6 BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
7 System.out.println("Enter the number of Threads");
8 int th=Integer.parseInt(br.readLine());
9 GradeCalculator obj=null;
10 String str="";
11 String[] details=new String[th];
12 for(int i=0;i<th;i++)
13 {
14 System.out.println("Enter the String");
15 str=br.readLine();
16 details[i]=str;
17 }
18 for(int i=0;i<th;i++)
19 {
20 String sp[]=details[i].split(":");
21 int k=0;
22 int arr[]=new int[sp.length];
23 for(int j=1;j<sp.length;j++)
24 arr[k++]=Integer.parseInt(sp[j]);
25 obj=new GradeCalculator(sp[0],arr);
26 obj.start();
27 try{
28 Thread.sleep(1000);
29 }
30 catch(Exception e)
31 {
32 System.out.println(e);
33 }
34 }
35 //Fill your code here
36
37 }
38
39 }
GradeCalculator.java
1
2 public class GradeCalculator extends Thread{
3 private String studName;
4 private char result;
5 private int[] marks;
6 public String getStudName()
7 {
8 return studName;
9 }
10 public void setStudName()
11 {
12 this.studName=studName;
13 }
14 public char getResult()
15 {
16 return result;
17 }
18 public void setResult(char result)
19 {
20 this.result=result;
21 }
22 public int[] getMarks()
23 {
24 return marks;
25 }
26 public void setMarks(int[] marks)
27 {
28 this.marks=marks;
29 }
30 public GradeCalculator(String studName,int[] marks)
31 {
32 this.studName=studName;
33 this.marks=marks;
34 }
35 public void run()
36 {
37 int sum=0;
38 int[] score=getMarks();
39 for(int i=0;i<score.length;i++)
40 sum=sum+score[i];
41 if((400<=sum)&&(sum<=500))
42 System.out.println(getStudName()+":"+'A');
43 if((300<=sum)&&(sum<=399))
44 System.out.println(getStudName()+":"+'B');
45 if((200<=sum)&&(sum<=299))
46 System.out.println(getStudName()+":"+'C');
47 if(sum<200)
48 System.out.println(getStudName()+":"+'E');
49 }
50 }
Grade
Reviewed on Friday, 7 January 2022, 7:24 PM by Automatic grade
Grade 100 / 100
Assessment report
[+]Grading and Feedback
You being his best friend, help him in completing his weekend assignment. You need to
implement a java program using inner class concept to display the details available in
primaryDataSet, secondaryDataSet and Query.
Create a class called TestApplication with the main method and get the inputs for primary data
set and secondary data set like theatreId, theatreName, location, noOfScreen and ticketCost,
and details of Query like queryId and queryCategory from the user.
Display the details of primary data set, secondary data set and Query as shown in the sample
input and output.
Note:
In the Sample Input / Output provided, the highlighted text in bold corresponds to the input given
by the user and the remaining text represents the output.
PNR6001
KV cinemas
Chennai
120
RNV5001
Inoxe
Bangalore
5
Enter the ticket cost
150
Q510
DML
Theatre id : PNR6001
Location : Chennai
No of Screen : 8
Theatre id : RNV5001
Location : Bangalore
No of Screen : 5
Query id : Q510
Automatic evaluation[+]
Query.java
1
2 //Write the required business logic as expected in the question description
3
4 public class Query {
5 private String queryId;
6 private String queryCategory;
7 private DataSet primaryDataSet;
8 private DataSet secondaryDataSet;
9
10 @Override
11 public String toString()
12 {
13 String g="";
14 g+=("Primary data set"+"\n");
15 g+=("Theatre id :"+primaryDataSet.getTheatreId()+"\n");
16 g+=("Theatre name :"+primaryDataSet.getTheatreName()+"\n");
17 g+=("Location :"+primaryDataSet.getLocation()+"\n");
18 g+=("No of Screen :"+primaryDataSet.getNoOfScreen()+"\n");
19 g+=("Ticket Cost :"+primaryDataSet.getTicketCost()+"\n");
20
21 g+=("Secondary data set"+"\n");
22 g+=("Theatre id :"+secondaryDataSet.getTheatreId()+"\n");
23 g+=("Theatre name :"+secondaryDataSet.getTheatreName()+"\n");
24 g+=("Location :"+secondaryDataSet.getLocation()+"\n");
25 g+=("No of Screen :"+secondaryDataSet.getNoOfScreen()+"\n");
26 g+=("Ticket Cost :"+secondaryDataSet.getTicketCost()+"\n");
27 g+=("Query id : "+queryId+"\n");
28 g+=("Query category : "+queryCategory+"\n");
29
30 return g;
31 }
32 public class DataSet{
33 private String theatreId;
34 private String theatreName;
35 private String location;
36 private int noOfScreen;
37 private double ticketCost;
38
39 public double getTicketCost()
40 {
41 return ticketCost;
42 }
43 public void setTicketCost(double a)
44 {
45 ticketCost=a;
46 }
47
48 public int getNoOfScreen()
49 {
50 return noOfScreen;
51 }
52 public void setNoOfScreen(int a)
53 {
54 noOfScreen=a;
55 }
56 public String getLocation()
57 {
58 return location;
59 }
60 public void setLocation(String a)
61 {
62 location=a;
63 }
64 public String getTheatreName ()
65 {
66 return theatreName;
67 }
68 public void setTheatreName(String a)
69 {
70 theatreName=a;
71 }
72
73 public String getTheatreId()
74 {
75 return theatreId;
76 }
77 public void setTheatreId(String a)
78 {
79 theatreId=a;
80 }
81 }
82 public void setSecondaryDataSet(DataSet pD)
83 {
84 this.secondaryDataSet=pD;
85 }
86 public DataSet getSecondaryDataSet()
87 {
88 return this.secondaryDataSet;
89 }
90 public void setPrimaryDataSet(DataSet pD)
91 {
92 this.primaryDataSet=pD;
93 }
94 public DataSet getPrimaryDataSet()
95 {
96 return this.primaryDataSet;
97 }
98 public void setQueryId (String queryId)
99 {
100 this.queryId=queryId;
101 }
102 public void setQueryCategory(String queryCategory)
103 {
104 this.queryCategory=queryCategory;
105 }
106 public String getQueryId()
107 {
108 return this.queryId;
109 }
110 public String getQueryCategory()
111 {
112 return this.queryCategory;
113 }
114
115 }
TestApplication.java
1 import java.util.*;
2 public class TestApplication {
3 //Write the required business logic as expected in the question description
4 public static void main (String[] args) {
5 Scanner sc= new Scanner (System.in);
6 Query q= new Query();
7 Query.DataSet pd= q.new DataSet();
8 Query.DataSet sd= q.new DataSet();
9 System.out.println("Enter the Details for primary data set");
10 System.out.println("Enter the theatre id");
11 pd.setTheatreId(sc.nextLine());
12 System.out.println("Enter the theatre name");
13 pd.setTheatreName(sc.nextLine());
14 System.out.println("Enter the location");
15 pd.setLocation(sc.nextLine());
16 System.out.println("Enter the no of screens");
17 pd.setNoOfScreen(sc.nextInt());
18 System.out.println("Enter the ticket cost");
19 pd.setTicketCost(sc.nextDouble());
20 System.out.println("Enter the Details for secondary data set");
21 System.out.println("Enter the theatre id");
22
23 String id2=sc.next();
24 //System.out.println(id2);
25 sd.setTheatreId(id2);
26 System.out.println("Enter the theatre name");
27 sc.nextLine();
28 sd.setTheatreName(sc.nextLine());
29 System.out.println("Enter the location");
30 String gll=sc.nextLine();
31 sd.setLocation(gll);
32 System.out.println("Enter the no of screens");
33
34 //System.out.println(gll);
35 //String pp=sc.nextLine();
36 //System.out.println(pp);
37
38 sd.setNoOfScreen(sc.nextInt());
39 System.out.println("Enter the ticket cost");
40 sd.setTicketCost(sc.nextDouble());
41 sc.nextLine();
42 System.out.println("Enter the query id");
43 q.setQueryId(sc.nextLine());
44 System.out.println("Enter the query category");
45 q.setQueryCategory(sc.nextLine());
46
47 q.setSecondaryDataSet(sd);
48 q.setPrimaryDataSet(pd);
49 System.out.println(q.toString());
50 }
51 }
Grade
Reviewed on Friday, 17 December 2021, 6:59 PM by Automatic grade
Grade 100 / 100
Assessment report
[+]Grading and Feedback
You being their software consultant have been approached by them to develop an application
which can be used for managing their business. You need to implement a java program to view
all the flight based on source and destination.
int
noOfSeats
double
flightFare
Note: The class and methods should be declared as public and all the attributes should be
declared as private.
Requirement 1: Retrieve all the flights with the given source and destination
The customer should have the facility to view flights which are from a particular source to
destination. Hence the system should fetch all the flight details for the given source and
destination from the database. Those flight details should be added to a ArrayList and return the
same.
The flight table is already created at the backend. The structure of flight table is:
Column Name Datatype
flightId int
source varchar2(30)
destination varchar2(30)
noofseats int
flightfare number(8,2)
To connect to the database you are provided with database.properties file and DB.java file. (Do
not change any values in database.properties file)
Create a class called Main with the main method and get the inputs
like source and destination from the user.
Display the details of flight such as flightId, noofseats and flightfare for all the flights returned
as ArrayList<Flight> from the
method viewFlightBySourceDestination in FlightManagementSystem class.
If no flight is available in the list, the output should be “No flights available for the given source
and destination”.
Note:
In the Sample Input / Output provided, the highlighted text in bold corresponds to the input given
by the user and the remaining text represents the output.
Malaysia
Singapore
Malaysia
Dubai
Automatic evaluation[+]
Flight.java
1
2 public class Flight {
3
4 private int flightId;
5 private String source;
6 private String destination;
7 private int noOfSeats;
8 private double flightFare;
9 public int getFlightId() {
10 return flightId;
11 }
12 public void setFlightId(int flightId) {
13 this.flightId = flightId;
14 }
15 public String getSource() {
16 return source;
17 }
18 public void setSource(String source) {
19 this.source = source;
20 }
21 public String getDestination() {
22 return destination;
23 }
24 public void setDestination(String destination) {
25 this.destination = destination;
26 }
27 public int getNoOfSeats() {
28 return noOfSeats;
29 }
30 public void setNoOfSeats(int noOfSeats) {
31 this.noOfSeats = noOfSeats;
32 }
33 public double getFlightFare() {
34 return flightFare;
35 }
36 public void setFlightFare(double flightFare) {
37 this.flightFare = flightFare;
38 }
39 public Flight(int flightId, String source, String destination,
40 int noOfSeats, double flightFare) {
41 super();
42 this.flightId = flightId;
43 this.source = source;
44 this.destination = destination;
45 this.noOfSeats = noOfSeats;
46 this.flightFare = flightFare;
47 }
48
49
50
51 }
52
FlightManagementSystem.java
1 import java.sql.Connection;
2 import java.sql.ResultSet;
3 import java.sql.SQLException;
4 import java.util.ArrayList;
5 import java.util.List;
6 import java.sql.PreparedStatement;
7 public class FlightManagementSystem {
8 public ArrayList <Flight> viewFlightBySourceDestination(String source,String destination){
9 Connection conn = null;
10 ResultSet Rs = null;
11 String sql = "select * from flight where source=? and destination=? order by flightid";
12 ArrayList<Flight> flight = new ArrayList<>();
13 try{
14 conn = DB.getConnection();
15 PreparedStatement ps = conn.prepareStatement(sql);
16
17 ps.setString(1, source);
18 ps.setString(2, destination);
19
20 Rs=ps.executeQuery();
21 while(Rs.next()){
22 Flight F = new Flight(Rs.getInt(1),source,destination,Rs.getInt(4),Rs.getInt(5));
23 flight.add(F);
24 }
25 }catch(ClassNotFoundException e){
26 e.printStackTrace();
27 }catch(SQLException e){
28 e.printStackTrace();
29 }
30
31 return flight;
32 }
33 }
Main.java
1 import java.util.Comparator;
2 import java.util.Scanner;
3 import java.util.ArrayList;
4
5
6 public class Main{
7 public static void main(String[] args){
8 Scanner sc=new Scanner(System.in);
9 // fill your code here
10 System.out.println("Enter the source");
11 String source=sc.nextLine();
12 System.out.println("Enter the destination");
13 String destination=sc.nextLine();
14 ArrayList<Flight> flight = new
FlightManagementSystem().viewFlightBySourceDestination(source,destination);
15 if(flight.isEmpty())
16 {
17 System.out.println("No flights available for the given source and destination");
18
19 }
20 else
21 {
22 System.out.println("Flightid Noofseats Flightfare");
23 for(Flight f : flight)
24 {
25 System.out.println(f.getFlightId()+" "+f.getNoOfSeats()+" "+f.getFlightFare());
26 }
27 }
28
29
30 }
31 }
DB.java
1 import java.io.FileInputStream;
2 import java.io.IOException;
3 import java.sql.Connection;
4 import java.sql.DriverManager;
5 import java.sql.SQLException;
6 import java.util.Properties;
7
8 public class DB {
9
10 private static Connection con = null;
11 private static Properties props = new Properties();
12
13
14 //ENSURE YOU DON'T CHANGE THE BELOW CODE WHEN YOU SUBMIT
15 public static Connection getConnection() throws ClassNotFoundException, SQLException {
16 try{
17
18 FileInputStream fis = null;
19 fis = new FileInputStream("database.properties");
20 props.load(fis);
21
22 // load the Driver Class
23 Class.forName(props.getProperty("DB_DRIVER_CLASS"));
24
25 // create the connection now
26 con =
DriverManager.getConnection(props.getProperty("DB_URL"),props.getProperty("DB_USERNAME"),props.getPr
operty("DB_PASSWORD"));
27 }
28 catch(IOException e){
29 e.printStackTrace();
30 }
31 return con;
32 }
33 }
34
database.properties
1 #IF NEEDED, YOU CAN MODIFY THIS PROPERTY FILE
2 #ENSURE YOU ARE NOT CHANGING THE NAME OF THE PROPERTY
3 #YOU CAN CHANGE THE VALUE OF THE PROPERTY
4 #LOAD THE DETAILS OF DRIVER CLASS, URL, USERNAME AND PASSWORD IN DB.java using this
properties file only.
5 #Do not hard code the values in DB.java.
6
7 DB_DRIVER_CLASS=com.mysql.jdbc.Driver
8 DB_URL=jdbc:mysql://localhost:3306/${sys:DB_USERNAME}
9 DB_USERNAME=${sys:DB_USERNAME}
10 DB_PASSWORD=${sys:DB_USERNAME}
11
Grade
Reviewed on Wednesday, 12 May 2021, 6:31 AM by Automatic grade
Grade 100 / 100
Assessment report
[+]Grading and Feedback
CLUB MEMBER DETAILS
ClubMember.java*
this.memberId = memberId;
return memberId;
this.memberName = memberName;
return memberName;
this.memberType = memberType;
return memberType;
return membershipFees;
this.memberId = memberId;
this.memberName = memberName;
this.memberType = memberType;
Main.java*
import java.util.Scanner;
sc.nextLine();
System.out.println("Enter Name");
clubMemberObj.calculateMembershipFees();
}
CreditCardValidator
CreditCard.java*
package com.cts.entity;
public CreditCard() {
super();
this.number = number;
return number;
this.number = number;
CreditCardService.java*
package com.cts.services;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.nio.file.*;
import com.cts.entity.CreditCard;
//check whether the card is blocklisted and card contains only 16 digits
String msg=null;
if(validateAgainstBlocklist(card, fileName))
msg="Card is blocked";
else if(validateNumber(card.getNumber()))
else
msg="valid card";
return msg;
if(card.getNumber().equalsIgnoreCase(str2) || card.getNumber().equalsIgnoreCase(str3))
{
bol=true;
else{
bol=false;
return bol;
boolean bol=true;
if(len!=16)
bol=true;
else{
bol=false;
return bol;
// Get the blocklisted no's from the file and return list of numbers
for(int i=0;i<dig1.length;i++)
li.add(dig1[i]);
}
return li;
SkeletonValidator.java*
package com.cts.skeletonvalidator;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;
public SkeletonValidator() {
validateClassName("com.cts.entity.CreditCard");
validateClassName("com.cts.services.CreditCardService");
validateMethodSignature(
"validate:String,validateAgainstBlocklist:boolean,validateNumber:boolean,getBlockListNumbers:List","com.c
ts.services.CreditCardService");
try {
Class.forName(className);
iscorrect = true;
} catch (ClassNotFoundException e) {
LOG.log(Level.SEVERE, "You have changed either the " + "class name/package. Use the correct package "
} catch (Exception e) {
LOG.log(Level.SEVERE, "There is an error in validating the " + "Class Name. Please manually verify that the "
return iscorrect;
try {
String[] methodSignature;
methodSignature = singleMethod.split(":");
methodName = methodSignature[0];
returnType = methodSignature[1];
cls = Class.forName(className);
if (methodName.equals(findMethod.getName())) {
foundMethod = true;
if (!(findMethod.getReturnType().getSimpleName().equals(returnType))) {
errorFlag = true;
LOG.log(Level.SEVERE, " You have changed the " + "return type in '" + methodName
+ "' method. Please stick to the " + "skeleton provided");
} else {
if (!foundMethod) {
errorFlag = true;
LOG.log(Level.SEVERE, " Unable to find the given public method " + methodName
+ ". Do not change the " + "given public method name. " +
"Verify it with the skeleton");
if (!errorFlag) {
} catch (Exception e) {
CreditCardValidatorMain.java*
package com.cts;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import com.cts.entity.CreditCard;
import com.cts.services.CreditCardService;
import com.cts.skeletonvalidator.SkeletonValidator;
new SkeletonValidator();
creditCard.setNumber(cardNumber);
//Write your code here read card numnber and create CreditCard object based on cardnumber
System.out.println(validationMessage);
}
ESHOPPING
Main.java*
package com.cts.eshopping.main;
import com.cts.eshopping.orderservice.CartService;
import com.cts.eshopping.skeletonvalidator.SkeletonValidator;
import com.cts.eshopping.vo.OrderLineItem;
System.out.println(cs.calculateDiscount(amt));
}
CartService.java*/orderService
package com.cts.eshopping.orderservice;
import com.cts.eshopping.vo.OrderLineItem;
/**
*/
/**
* Method to calculate total purchase amount for all the order line items
* @param orderLineItems
* @return totalOrderAmount
*/
double totalOrderAmount = 0;
int qt =0;
for(int i=0;i<orderLineItems.length;i++){
qt = orderLineItems[i].quantity;
cost = orderLineItems[i].itemCostPerQuantity;
totalOrderAmount += (qt*cost);
/**
* @param totalOrderAmount
* @return discount
*/
if(totalOrderAmount<1000){
discount = (totalOrderAmount*10)/100;
discount = (totalOrderAmount*20)/100;
else if(totalOrderAmount>=10000){
discount = (totalOrderAmount*30)/100;
/**
* Method to verify if the order line item is flagged as Bulk Order or not
* @param lineItem
* @return boolean
*/
boolean result=false;
if(lineItem.quantity>5){
result = true;
result=false;
}
/**
* @param orderLineItems
* @return
*/
int count = 0;
for(int i=0;i<orderLineItems.length;i++){
if(isBulkOrder(orderLineItems[i])){
count++;
SkeletonValidator.java*
package com.cts.eshopping.skeletonvalidator;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* @author 222805
* This class is used to verify if the Code Skeleton is intact and not modified by participants thereby ensuring smooth
auto evaluation
*/
public class SkeletonValidator {
public SkeletonValidator() {
validateClassName("com.cts.eshopping.orderservice.CartService");
validateClassName("com.cts.eshopping.vo.OrderLineItem");
validateMethodSignature(
"calculateOrderTotalAmount:double,calculateDiscount:double,isBulkOrder:boolean,countOfBulkOrderLineIt
ems:int",
"com.cts.eshopping.orderservice.CartService");
try {
Class.forName(className);
iscorrect = true;
} catch (ClassNotFoundException e) {
LOG.log(Level.SEVERE, "You have changed either the " + "class name/package. Use the correct package "
} catch (Exception e) {
return iscorrect;
}
protected final void validateMethodSignature(String methodWithExcptn, String className) {
try {
String[] methodSignature;
methodSignature = singleMethod.split(":");
methodName = methodSignature[0];
returnType = methodSignature[1];
cls = Class.forName(className);
if (methodName.equals(findMethod.getName())) {
foundMethod = true;
if (!(findMethod.getReturnType().getName().equals(returnType))) {
errorFlag = true;
LOG.log(Level.SEVERE, " You have changed the " + "return type in '" + methodName
+ "' method. Please stick to the " + "skeleton provided");
} else {
if (!foundMethod) {
errorFlag = true;
LOG.log(Level.SEVERE, " Unable to find the given public method " + methodName
+ ". Do not change the " + "given public method name. " + "Verify it with the skeleton");
if (!errorFlag) {
} catch (Exception e) {
OrderLineItem.java*
package com.cts.eshopping.vo;
/**
*/
return itemId;
}
public void setItemId(String itemId){
this.itemId = itemId;
return itemName;
this.itemName = itemName;
return itemCostPerQuantity;
this.itemCostPerQuantity = itemCostPerQuantity;
return quantity;
this.quantity = quantity;
this.itemId = itemId;
this.itemName = itemName;
this.itemCostPerQuantity=itemCostPerQuantity;
this.quantity = quantity;
}
Fixed Deposit Details
FDScheme.java*
import java.util.*;
class FDScheme{
super();
this.schemeNo=schemeNo;
this.depositAmt=depositAmt;
this.period=period;
calculateInterestRate();
return schemeNo;
this.schemeNo=schemeNo;
return depositAmt;
this.depositAmt=depositAmt;
return period;
return rate;
this.rate=rate;
this.rate=(float)5.5;
this.rate=(float)6.25;
this.rate=(float)7.5;
Main.java*
import java.util.Scanner;
int no=sc.nextInt();
sc.nextLine();
double amt=sc.nextDouble();
int prd=sc.nextInt();
FDScheme obj=new
FDScheme(no,amt,prd);
}
GPA CALCULATION
UserInterface.java*
package com.ui;
import com.utility.*;
import java.util.*;
gpa.setGradePointList(new ArrayList<Integer>());
int option=0;
double gpa1=0;
do
option = Integer.valueOf(sc.nextLine());
switch(option)
gpa.addGradePoint(grade);
break;
if(gpa1 > 0)
System.out.println("GPA Scored");
System.out.println(gpa1);
else
break;
case 3 : break;
}while(option!=3);
GPACalculator.java*
package com.utility;
import java.util.*;
return gradePointList;
this.gradePointList = gradePointList;
/*This method should add equivalent grade points based on the grade obtained by the student passed as
argument into gradePointList
Grade S A B C D E
Grade Point 10 9 8 7 6 5
For example if the gradeobtained is A, its equivalent grade points is 9 has to added into the
gradePointList*/
public void addGradePoint(char gradeObtained) {
if(gradeObtained == 'S')
gradePointList.add(10);
gradePointList.add(9);
gradePointList.add(8);
gradePointList.add(7);
gradePointList.add(6);
else
gradePointList.add(5);
/* This method should return the GPA of all grades scored in the semester
For Example:
double gpa=-1;
double total=0,value=0,size=0;
size = gradePointList.size();
if(size < 1)
return 0;
Iterator i = gradePointList.iterator();
while(i.hasNext())
value = (Integer)i.next();
total += value;
gpa = total/size;
return gpa;
}
HUNGER EATS
FoodProduct.java*
package com.bean;
return foodId;
this.foodId = foodId;
return foodName;
this.foodName = foodName;
return costPerUnit;
this.costPerUnit = costPerUnit;
return quantity;
this.quantity = quantity;
}
UserInterface.java*
package com.ui;
import java.util.Scanner;
import com.utility.Order;
import com.bean.FoodProduct;
int itemno;
String bank;
itemno=sc.nextInt();
for(int i=0;i<itemno;i++){
fd.setFoodId(sc.nextInt());
fd.setFoodName(sc.next());
fd.setCostPerUnit(sc.nextDouble());
fd.setQuantity(sc.nextInt());
z.addToCart(fd);
}
System.out.println("Enter the bank name to avail offer");
bank=sc.next();
z.findDiscount(bank);
Order.java*
package com.utility;
import java.util.*;
import com.bean.FoodProduct;
return discountPercentage;
this.discountPercentage = discountPercentage;
return foodList;
this.foodList = foodList;
}
//This method should set the discount percentage based on bank passed as argument
if(bankName.equals("HDFC")){
discountPercentage=15.0;
else if(bankName.equals("ICICI")){
discountPercentage=25.0;
else if(bankName.equals("CUB")){
discountPercentage=30.0;
else if(bankName.equals("SBI")){
discountPercentage=50.0;
else if(bankName.equals("OTHERS")){
discountPercentage=0.0;
//This method should add the FoodProduct Object into Food List
List<FoodProduct> f=getFoodList();
f.add(foodProductObject);
setFoodList(f);
double bill=0;
List<FoodProduct> f=getFoodList();
for(int i=0;i<f.size();i++){
//
// System.out.println(f.get(i).getCostPerUnit());
//
// System.out.println(f.get(i).getQuantity());
bill+=f.get(i).getQuantity()*f.get(i).getCostPerUnit()*1.0;
bill=bill-((bill*discountPercentage)/100);
return bill;
}
INSURANCE PREMIUM GENERATOR
PropertyDetails.java*
package com.cts.insurance.entity;
public PropertyDetails() {
return builtUpArea;
this.builtUpArea = builtUpArea;
return builtYear;
this.builtYear = builtYear;
this.reconstructionCost = reconstructionCost;
return householdValuation;
this.householdValuation = householdValuation;
return burglaryCoverReqd;
this.burglaryCoverReqd = burglaryCoverReqd;
return politicalUnrestCoverReqd;
this.politicalUnrestCoverReqd = politicalUnrestCoverReqd;
return sumAssured;
}
public void setSumAssured(Integer sumAssured) {
this.sumAssured = sumAssured;
super();
this.builtUpArea = builtUpArea;
this.builtYear=builtYear;
this.reconstructionCost = reconstructionCost;
this.householdValuation = householdValuation;
this.burglaryCoverReqd = burglaryCoverReqd;
this.politicalUnrestCoverReqd = politicalUnrestCoverReqd;
Constants.java*
package com.cts.insurance.misc;
CalculatePremiumService.java*
package com.cts.insurance.services;
import com.cts.insurance.entity.PropertyDetails;
import com.cts.insurance.misc.Constants;
import java.time.LocalDate;
double amountToBePaid = 0;
double additionalAmount1=0;
double additionalAmount2=0;
* calculatePremiumForPoliticalUnrestCoverage(propertyDetails, amountToBePaid)
* else return 0;
*/
if(!validatePropertyParameters(propertyDetails)) {
return 0;
amountToBePaid=calculatePremiumByPropertyAge(propertyDetails);
additionalAmount1=calculatePremiumForBurglaryCoverage(propertyDetails, amountToBePaid);
additionalAmount2=calculatePremiumForPoliticalUnrestCoverage(propertyDetails,
amountToBePaid);
return Math.round(amountToBePaid+additionalAmount1+additionalAmount2);
}
/*
* conditions to be checked
*/
return false;
return false;
return true;
//Use Constants.MIN_PREMIUM_AMOUNT
int sumAssured =
propertyDetails.getBuiltUpArea()*propertyDetails.getReconstructionCost()+propertyDetails.getHouseholdValuation(
);
propertyDetails.setSumAssured(sumAssured);
double premium = 0;
if(propertyAge>15) {
premium = Constants.MIN_PREMIUM_AMOUNT+(propertyDetails.getSumAssured()*0.35);
else if(propertyAge>=6) {
premium = Constants.MIN_PREMIUM_AMOUNT+(propertyDetails.getSumAssured()*0.2);
else {
premium = Constants.MIN_PREMIUM_AMOUNT+(propertyDetails.getSumAssured()*0.1);
return premium;
if(propertyDetails.getBurglaryCoverReqd().equalsIgnoreCase(Constants.YES)) {
return amount*.01;
return 0;
//Ex:-propertyDetails.getPoliticalUnrestCoverReqd().equalsIgnoreCase(Constants.YES) to check
condition
if(propertyDetails.getPoliticalUnrestCoverReqd().equalsIgnoreCase(Constants.YES)) {
return amount*.01;
return 0;
}
SkeletonValidator.java*
package com.cts.insurance.skeleton;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* @author
* This class is used to verify if the Code Skeleton is intact and not modified by participants thereby ensuring smooth
auto evaluation
*/
public SkeletonValidator() {
validateClassName("com.cts.insurance.entity.PropertyDetails");
validateClassName("com.cts.insurance.misc.Constants");
validateClassName("com.cts.insurance.services.CalculatePremiumService");
validateClassName("com.cts.insurance.InsurancePremiumGeneratorApp");
validateMethodSignature(
"checkOwnerDetails:boolean,getPremiumAmount:double,validatePropertyParameters:boolean,calculatePre
miumByPropertyAge:double,calculatePremiumForBurglaryCoverage:double,calculatePremiumForPoliticalUnrestCov
erage:double","com.cts.insurance.services.CalculatePremiumService");
try {
Class.forName(className);
iscorrect = true;
LOG.info("Class Name " + className + " is correct");
} catch (ClassNotFoundException e) {
LOG.log(Level.SEVERE, "You have changed either the " + "class name/package. Use the
correct package "+ "and class name as provided in the skeleton");
} catch (Exception e) {
LOG.log(Level.SEVERE,
"There is an error in validating the " + "Class Name. Please manually verify that the "
return iscorrect;
try {
String[] methodSignature;
methodSignature = singleMethod.split(":");
methodName = methodSignature[0];
returnType = methodSignature[1];
cls = Class.forName(className);
foundMethod = true;
if (!(findMethod.getReturnType().getSimpleName().equals(returnType))) {
errorFlag = true;
LOG.log(Level.SEVERE, " You have changed the " + "return type in '" +
methodName+ "' method. Please stick to the " + "skeleton provided");
} else {
if (!foundMethod) {
errorFlag = true;
LOG.log(Level.SEVERE, " Unable to find the given public method " + methodName
+ ". Do not change the " + "given public method name. " + "Verify it with the
skeleton");
if (!errorFlag) {
} catch (Exception e) {
}
InsurancePremiumGeneratorApp.java*
package com.cts.insurance;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import com.cts.insurance.entity.PropertyDetails;
import com.cts.insurance.misc.Constants;
import com.cts.insurance.services.CalculatePremiumService;
import com.cts.insurance.skeleton.SkeletonValidator;
Integer builtUpArea = 0;
Integer builtYear=0;
Integer reconstructionCost = 0;
//read name
name = br.readLine();
//read mobile
mobile = br.readLine();
if(premiumService.checkOwnerDetails(name, mobile)) {
//read builtUpArea
builtUpArea = Integer.parseInt(br.readLine());
//read builtYear
builtYear = Integer.parseInt(br.readLine());
//read reconstructionCost
reconstructionCost = Integer.parseInt(br.readLine());
System.out.println(
"Do you want to include valuation of HouseHold Articles? Please provide yes/no");
//read response
if(response.equalsIgnoreCase("yes")) {
//read householdValuation
householdValuation = Integer.parseInt(br.readLine());
burglaryCoverReqd = br.readLine();
System.out.println("Do you want to include Political unrest cover? Please provide yes/no");
//read politicalUnrestCoverReqd
politicalUnrestCoverReqd = br.readLine();
if(premiumAmount==0.0) {
}else {
}
NUMEROLOGY NUMBER
Main.java*
import java.util.Scanner;
int sum = 0;
return sum;
while (string.length() != 1) {
string = String.valueOf(getSum(Long.parseLong(string)));
return Integer.parseInt(string);
int oddCount = 0;
if (Character.digit(ch, 10) % 2 != 0) {
++oddCount;
}
return oddCount;
int evenCount = 0;
if (Character.digit(ch, 10) % 2 == 0) {
++evenCount;
return evenCount;
System.out.println("Sum of digits");
System.out.println(getSum(num));
System.out.println("Numerology number");
System.out.println(getNumerology(num));
System.out.println(getOddCount(num));
System.out.println(getEvenCount(num));
}
OIL STORES
Oil.java*
import java.util.Scanner;
this.name=name;
this.pack=pack;
this.category=category;
this.cost=cost;
this.name=name;
return name;
this.pack=pack;
return pack;
this.category=category;
return category;
}
this.cost=cost;
return cost;
float price=((qty*1000)/pack)*cost;
return price;
Main.java*
import java.util.Scanner;
String n=sc.next();
int pc=sc.nextInt();
System.out.println("Enter category");
char cat=sc.next().charAt(0);
System.out.println("Enter cost");
float c=sc.nextFloat();
obj.setName(n);
obj.setPack(pc);
obj.setCategory(cat);
obj.setCost(c);
float qty=sc.nextFloat();
}
PAYMENT-INHERITENCE
Bill.java*
Cheque cheque=(Cheque)payObj;
if(cheque.payAmount())
Cash cash=(Cash)payObj;
if(cash.payAmount())
Credit credit=(Credit)payObj;
if(credit.payAmount())
result="Payment done successfully via credit card. Remaining amount in your "+credit.getCardType()+" card
is "+credit.getCreditCardAmount();
return result;
}
Cash.java*
return cashAmount;
this.cashAmount = cashAmount;
Cheque.java
import java.util.*;
import java.util.GregorianCalendar;
import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;
import java.text.SimpleDateFormat;
this.chequeNo = chequeNo;
return chequeAmount;
this.chequeAmount = chequeAmount;
return dateOfIssue;
this.dateOfIssue = dateOfIssue;
myDate.setTime(date);
return (2020-myDate.get(Calendar.YEAR))*12+(0-myDate.get(Calendar.MONTH));
@Override
int months=findDifference(getDateOfIssue());
return (getChequeAmount()>=getDueAmount()&months<=6);
try{
catch(ParseException e)
e.printStackTrace();
Credit.java*
return creditCardNo;
this.creditCardNo = creditCardNo;
return cardType;
this.cardType = cardType;
return creditCardAmount;
super();
public Credit()
@Override
int tax=0;
boolean isDeducted=false;
switch(cardType)
tax=(int)(0.02*getDueAmount())+getDueAmount();
if(tax<=getCreditCardAmount())
setCreditCardAmount(getCreditCardAmount()-tax);
isDeducted=true;
break;
tax=(int)(0.05*getDueAmount())+getDueAmount();
if(tax<=getCreditCardAmount())
{
setCreditCardAmount(getCreditCardAmount()-tax);
isDeducted=true;
break;
tax=(int)(0.1*getDueAmount())+getDueAmount();
if(tax<=getCreditCardAmount())
setCreditCardAmount(getCreditCardAmount()-tax);
isDeducted=true;
break;
return isDeducted;
Payment.java*
return dueAmount;
this.dueAmount = dueamount;
return false;
}
Main.java*
import java.util.*;
int dueAmount=sc.nextInt();
String mode=sc.next();
switch(mode)
int cashAmount=sc.nextInt();
cash.setCashAmount(cashAmount);
cash.setDueAmount(dueAmount);
System.out.println(bill.processPayment(cash));
break;
String number=sc.next();
int chequeAmount=sc.nextInt();
String date=sc.next();
cheque.setChequeAmount(chequeAmount);
cheque.setChequeNo(number);
cheque.generateDate(date);
cheque.setDueAmount(dueAmount);
System.out.println(bill.processPayment(cheque));
break;
String cardType=sc.next();
credit.setCardType(cardType);
credit.setCreditCardNo(creditNumber);
credit.setDueAmount(dueAmount);
System.out.println(bill.processPayment(credit));
break;
default:
break;
sc.close();
}
POWER PROGRESS
Main.java*
import java.util.*;
int m=sc.nextInt();
if(m<=0){
System.out.println(""+m+" is an invalid");
return;
int n=sc.nextInt();
if(n<=0){
System.out.println(""+n+" is an invalid");
return;
if(m>=n){
return;
for(int i=1;i<=n;i++){
System.out.print((int)Math.pow(m,i)+" ");
}
PRIME NUMBERS ENDING WITH 1
Main.java*
import java.util.Scanner;
int last=0;
int flag = 0;
low = sc.nextInt();
high = sc.nextInt();
else {
int i = low;
int x = i % 10;
if (i % j != 0 && x == 1) {
flag = 1;
} else {
flag = 0;
break;
if (flag == 1 )
System.out.println(i);
i++;
}}}
SINGAPORE TOURISM
Main.java*
import java.util.*;
map.put("BEACH",270);
map.put("PILGRIMAGE",350);
map.put("HERITAGE",430);
map.put("HILLS",780);
map.put("FALLS",1200);
map.put("ADVENTURES",4500);
String pname=sc.next();
String name=sc.next();
if(!map.containsKey(name.toUpperCase()))
else
int nod=sc.nextInt();
if(nod<=0)
else
if(not<=0)
else
double d=(double)map.get(name.toUpperCase());
double totalcost=d*(double)not*(double)nod;
if(totalcost>=1000)
totalcost=totalcost-((totalcost*15)/100);
}
SUBSTITUTION CYPHER TECHNIQUE
Main.java*
import java.util.Scanner;
int shift = 7;
int f=0;
f=1;
alpha=(char)(alpha - shift);
decryptMessage=decryptMessage+alpha;
f=1;
alpha=(char)(alpha - shift);
decryptMessage=decryptMessage+alpha;
decryptMessage=decryptMessage+alpha;
}
if(decryptMessage.length() == 0 || f == 0){
System.exit(0);
System.out.println("Decrpted Text:\n"+decryptMessage);
}
ZEE ZEE BANK
Account.java*
long accountNumber;
double balanceAmount;
super();
this.accountNumber=accno;
this.balanceAmount=bal;
return accountNumber;
this.accountNumber=accno;
return balanceAmount;
this.balanceAmount=bal;
float total=(float)(balanceAmount+depositAmt);
balanceAmount=total;
float total;
if(withdrawAmt>balanceAmount){
System.out.println("Insufficient balance");
return false;
}else{
total=(float)(balanceAmount-withdrawAmt);
setBalanceAmount(total);
return true;
Main.java*
import java.util.Scanner;
ac.setAccountNumber(sc.nextLong());
ac.setBalanceAmount(sc.nextDouble());
ac.deposit(sc.nextDouble());
System.out.println();
ac.withdraw(sc.nextDouble());
}
THE NEXT RECHARGE DATE
Main.java*
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
System.out.println("Recharged date");
String date=br.readLine();
String currentDate="29/10/2019";
if(Main.isValidFormat(date)&&(Main.dateCompare(date,currentDate))){
System.out.println("Validity days");
int days=Integer.parseInt(br.readLine());
if(days>0)
System.out.println(Main.futureDate(date,days));
else
else
String regex="^(3[01]|[12][0-9]|0[1-9])/(1[0-2]|0[1-9])/[0-9]{4}$";
Pattern pattern=Pattern.compile(regex);
Matcher matcher=pattern.matcher((CharSequence)date);
return matcher.matches();
}
Date d1=sdformat.parse(date1);
Date d2=sdformat.parse(date2);
if((d1.compareTo(d2)<0)||(d1.compareTo(d2)==0))
return true;
else
return false;
Calendar c=Calendar.getInstance();
try{
Date mydate=sdformat.parse(date);
c.setTime(mydate);
c.add(Calendar.DATE, days);
}catch(ParseException e){
e.printStackTrace();
String toDate=sdformat.format(c.getTime());
return toDate;
}
A New You Spa
DiamondMembers.java*
super(customerId,customerName,mobileNumber,memberType,emailId);
/*this.customerId = customerId;
this.customerName = customerName;
this.mobileNumber = mobileNumber;
this.memberType = memberType;
this.emailId = emailId;*/
boolean b=true;
String s1 = this.customerId.toUpperCase();
String regex="[DIAMOND]{7}[0-9]{3}";
if(s1.matches(regex)){
b=true;
else{
b=false;
return b;
double updateamount=purchaseAmount-discount;
return updateamount;
GoldMembers.java*
super(customerId,customerName,mobileNumber,memberType,emailId);
boolean b=true;
String s1 = this.customerId.toUpperCase();
String regex="[GOLD]{4}[0-9]{3}";
if(s1.matches(regex)){
b=true;
else{
b=false;
return b;
double discount=purchaseAmount*0.15;
double updateamount=purchaseAmount-discount;
return updateamount;
}
Members.java*
return customerId;
this.customerId = customerId;
return customerName;
this.customerName = customerName;
return mobileNumber;
this.mobileNumber = mobileNumber;
return memberType;
return emailId;
this.emailId = emailId;
public Members(String customerId, String customerName, long mobileNumber, String memberType, String
emailId) {
this.customerId = customerId;
this.customerName = customerName;
this.mobileNumber = mobileNumber;
this.memberType = memberType;
this.emailId = emailId;
PlatinumMembers.java*
super(customerId,customerName,mobileNumber,memberType,emailId);
/*customerId = customerId;
customerName = customerName;
mobileNumber = mobileNumber;
memberType = memberType;
emailId = emailId;
*/
}
public boolean validateCusomerId(){
boolean b=true;
String s1 = this.customerId.toUpperCase();
String regex="[PLATINUM]{8}[0-9]{3}";
if(s1.matches(regex)){
b=true;
else{
b=false;
return b;
double discount=purchaseAmount*0.3;
double updateamount=purchaseAmount-discount;
return updateamount;
UserInterface.java*
import java.util.Scanner;
String cname=sc.nextLine();
long mob=sc.nextLong();
sc.nextLine();
String mem=sc.nextLine();
String email=sc.nextLine();
double amount=sc.nextDouble();
double res=0.0;
if(d.validateCusomerId()){
res= d.calculateDiscount(amount);
System.out.println("Name :"+d.getCustomerName());
System.out.println("Id :"+d.getCustomerId());
System.out.println("Email Id :"+d.getEmailId());
} else if(g.validateCusomerId()){
res= g.calculateDiscount(amount);
System.out.println("Name :"+g.getCustomerName());
System.out.println("Id :"+g.getCustomerId());
System.out.println("Email Id :"+g.getEmailId());
} else if(p.validateCusomerId()){
res= p.calculateDiscount(amount);
System.out.println("Name :"+p.getCustomerName());
System.out.println("Id :"+p.getCustomerId());
System.out.println("Email Id :"+p.getEmailId());
} else{
}
BATTING AVERAGE
UserInterface.java*
package com.ui;
import com.utility.Player;
import java.util.ArrayList;
import java.util.Scanner;
player.setScoreList(new ArrayList<>());
boolean flag=true;
while(flag)
System.out.println("3. Exit");
int choice=sc.nextInt();
switch(choice)
case 1: {
int runScored=sc.nextInt();
player.addScoreDetails(runScored);
break;
case 2: {
System.out.println(player.getAverageRunScored());
break;
}
case 3: {
flag=false;
break;
Player.java*
package com.utility;
import java.util.List;
return scoreList;
this.scoreList = scoreList;
//This method should add the runScored passed as the argument into the scoreList
scoreList.add(runScored);
/* This method should return the average runs scored by the player
Average runs can be calculated based on the sum of all runScored available in the scoreList divided by the
number of elements in the scoreList.
For Example:
List contains[150,50,50]
*/
if(scoreList.isEmpty()) {
return 0.0;
int size=scoreList.size();
int totalScore=0;
totalScore+=score;
}
Change The Cash
Main.java*
import java.util.*;
String a = sc.next();
if(a.length() < 3) {
return;
return;
int j = 0;
arr1[j++] = arr[i];
if(j!=0) {
System.out.print(arr1[i]);
return;
char b = sc.next().charAt(0);
int present = 0;
if(arr[i] == Character.toUpperCase(b)) {
arr[i] = Character.toLowerCase(b);
present = 1;
arr[i] = Character.toUpperCase(b);
present = 1;
if(present == 0) {
else {
System.out.print(arr[i]);
}
Check Number Type
NumberType.java*
NumberTypeUtility.java*
import java.util.Scanner;
int n=sc.nextInt();
if(isOdd().checkNumberType(n))
System.out.println(n+" is odd");
else
}
Cheque Payment Process
PaymentDao.java*
package com.cts.paymentProcess.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.cts.paymentProcess.model.Payment;
import com.cts.paymentProcess.util.DatabaseUtil;
connection=DatabaseUtil.getConnection();
PreparedStatement statement=null;
ResultSet resultSet=null;
try {
resultSet=statement.executeQuery();
while(resultSet.next()){
payment.setCustomerNumber(resultSet.getInt("customerNumber"));
payment.setChequeNumber(resultSet.getString("chequeNumber"));
payment.setPaymentDate(resultSet.getDate("paymentDate"));
payment.setAmount(resultSet.getInt("amount"));
paymentList.add(payment);
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
try{
resultSet.close();
statement.close();
}catch(Exception e){
e.printStackTrace();
} }
return paymentList;
Payment.java*
package com.cts.paymentProcess.model;
import java.util.Date;
return customerNumber;
}
public void setCustomerNumber(int customerNumber) {
this.customerNumber = customerNumber;
return chequeNumber;
this.chequeNumber = chequeNumber;
return paymentDate;
this.paymentDate = paymentDate;
return amount;
this.amount = amount;
@Override
}
PaymentService.java*
package com.cts.paymentProcess.service;
import java.util.*;
import java.util.Calendar;
import java.util.List;
import java.util.stream.Collectors;
import com.cts.paymentProcess.dao.PaymentDao;
import com.cts.paymentProcess.model.Payment;
List<Payment> list=paymentDao.getAllRecord();
list2 = list.stream().filter(x->x.getCustomerNumber()==customerNumber).collect(Collectors.toList());
return list2;
List<Payment> list=paymentDao.getAllRecord();
list2 = list.stream().filter(x->x.getPaymentDate().getYear()==(year-
1900)).sorted(Comparator.comparingInt(Payment::getAmount)).collect(Collectors.toList());
return list2;
}
SkeletonValidator.java*
package com.cts.paymentProcess.skeletonValidator;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;
public SkeletonValidator(){
validateClassName("com.cts.paymentProcess.dao.PaymentDao");
validateMethodSignature("getAllRecord:java.util.List","com.cts.paymentProcess.dao.PaymentDao");
validateClassName("com.cts.paymentProcess.model.Payment");
validateMethodSignature("toString:java.lang.String","com.cts.paymentProcess.model.Payment");
validateClassName("com.cts.paymentProcess.service.PaymentService");
validateMethodSignature("findCustomerByNumber:java.util.List,findCustomerByYear:java.util.List","com.cts.
paymentProcess.service.PaymentService");
validateClassName("com.cts.paymentProcess.util.DatabaseUtil");
validateMethodSignature("getConnection:java.sql.Connection","com.cts.paymentProcess.util.DatabaseUtil")
;
try {
Class.forName(className);
iscorrect = true;
} catch (ClassNotFoundException e) {
LOG.log(Level.SEVERE, "You have changed either the " + "class name/package. Use the
correct package "
} catch (Exception e) {
LOG.log(Level.SEVERE,
"There is an error in validating the " + "Class Name. Please manually verify
that the "
return iscorrect;
try {
String[] methodSignature;
methodSignature = singleMethod.split(":");
methodName = methodSignature[0];
returnType = methodSignature[1];
cls = Class.forName(className);
if (methodName.equals(findMethod.getName())) {
foundMethod = true;
if (!(findMethod.getReturnType().getName().equals(returnType))) {
errorFlag = true;
} else {
if (!foundMethod) {
errorFlag = true;
+ ". Do not change the " + "given public method name. " +
"Verify it with the skeleton");
if (!errorFlag) {
} catch (Exception e) {
LOG.log(Level.SEVERE,
" There is an error in validating the " + "method structure. Please manually
verify that the "
DatabaseUtil.java*
package com.cts.paymentProcess.util;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
import java.util.ResourceBundle;
private DatabaseUtil() {
//ENSURE YOU DON'T CHANGE THE BELOW CODE WHEN YOU SUBMIT
try{
FileInputStream fis = null;
props.load(fis);
try {
Class.forName(props.getProperty("DB_DRIVER_CLASS"));
} catch (ClassNotFoundException e) {
e.printStackTrace();
try {
con =
DriverManager.getConnection(props.getProperty("DB_URL"),props.getProperty("DB_USERNAME"),props.getPropert
y("DB_PASSWORD"));
} catch (SQLException e) {
e.printStackTrace();
catch(IOException e){
e.printStackTrace();
return con;
}
App.java(Main)*
package com.cts.paymentProcess;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Scanner;
import com.cts.paymentProcess.model.Payment;
import com.cts.paymentProcess.service.PaymentService;
import com.cts.paymentProcess.skeletonValidator.SkeletonValidator;
new SkeletonValidator();
Payment payment=null;
do{
System.out.println("Select Option:");
int choice=scanner.nextInt();
switch(choice){
int number=scanner.nextInt();
if(numberList.size()==0){
}else{
System.out.format("%15s%15s%15s%15s\n","Customer Number","Cheque Number","Payment
Date","Amount");
numberList.stream()
.forEach(System.out::println);
break;
int year=scanner.nextInt();
if(yearList.size()==0){
}else{
yearList.stream()
.forEach(System.out::println);
break;
case 3:System.exit(0);
default:System.out.println("\nWrong Choice\n");
}while(true);
}
Employee Eligibility for Promotion
Main.java*
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.*;
import java.util.TreeMap;
import java.util.Date;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
//System.out.println("In-time");
String fdt=currTime.format(formatter);
// System.out.println(fdt);
int no = sc.nextInt();
String id = sc.next();
m.put(id, date);
}
int count = 0;
int val = 0;
if (entry.getValue().matches("(0[1-9]|[1-2][0-9]|3[0-1])/(0[1-9]|1[0-2])/[0-9]{4}"))
val++;
if (lin >= 5)
count++;
System.out.println(entry.getKey());
else
break;
}
Exam Scheduler
AssessmentDao.java*
package com.cts.cc.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.Period;
import java.util.List;
import java.sql.*;
import com.cts.cc.model.Assessment;
import com.cts.cc.util.DatabaseUtil;
if(assessments==null || assessments.isEmpty()) {
int rowsCount = 0;
try{
for(Assessment a:assessments)
st.setString(1,a.getExamCode());
st.setString(2,a.getExamTitle());
st.setString(3,a.getExamDate().toString());
st.setString(4,a.getExamTime().toString());
st.setString(5,a.getExamDuration().toString());
st.setString(6,a.getEvalDays().toString());
int rs=st.executeUpdate();
if(rs!=-1)
rowsCount=rowsCount+1;
} catch(SQLException e){
return rowsCount;
PreparedStatement ps = conn.prepareStatement(sql);
ps.setString(1, code);
ResultSet rs = ps.executeQuery();
if(rs.next()) {
assessment.setExamCode(rs.getString(1));
assessment.setExamTitle(rs.getString(2));
assessment.setExamDate(LocalDate.parse(rs.getString(3)));
assessment.setExamTime(LocalTime.parse(rs.getString(4)));
assessment.setExamDuration(Duration.parse(rs.getString(5)));
assessment.setEvalDays(Period.parse(rs.getString(6)));
return assessment;
}
GenerateAssessmentFunction.java*
package com.cts.cc.functions;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.Period;
import java.util.function.Function;
import com.cts.cc.model.Assessment;
@Override
String temp[]=t.split(",");
Assessment a = new
Assessment(temp[0],temp[1],LocalDate.parse(temp[2]),LocalTime.parse(temp[3]),Duration.parse(temp[4]),Period.p
arse(temp[5]));
return a;
Assessment.java*
package com.cts.cc.model;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.Period;
import java.time.format.DateTimeFormatter;
public Assessment(String examCode, String examTitle, LocalDate examDate, LocalTime examTime, Duration
examDuration,
Period evalDays) {
super();
this.examCode = examCode;
this.examTitle = examTitle;
this.examDate = examDate;
this.examTime = examTime;
this.examDuration = examDuration;
this.evalDays = evalDays;
public Assessment() {
return examCode;
this.examCode = examCode;
return examTitle;
}
public void setExamTitle(String examTitle) {
this.examTitle = examTitle;
return examDate;
this.examDate = examDate;
return examTime;
this.examTime = examTime;
return examDuration;
this.examDuration = examDuration;
return evalDays;
this.evalDays = evalDays;
}
DateTimeFormatter date1=DateTimeFormatter.ofPattern("dd-MMM-y");
DateTimeFormatter date2=DateTimeFormatter.ofPattern("HH:mm");
LocalTime t=examTime.plus(examDuration);
String d=DateTimeFormatter.ofPattern("HH:mm").format(t);
LocalDate t1=examDate.plus(evalDays);
String d1=DateTimeFormatter.ofPattern("dd-MMM-y").format(t1);
System.out.println("Title: "+examTitle);
DatabaseUtil.java*
package com.cts.cc.util;
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
//ENSURE YOU DON'T CHANGE THE BELOW CODE WHEN YOU SUBMIT
try{
props.load(fis);
Class.forName(props.getProperty("DB_DRIVER_CLASS"));
con =
DriverManager.getConnection(props.getProperty("DB_URL"),props.getProperty("DB_USERNAME"),props.getPropert
y("DB_PASSWORD"));
catch(IOException e){
e.printStackTrace();
return con;
FileUtil.java*
package com.cts.cc.util;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.io.*;
import java.util.*;
import com.cts.cc.functions.GenerateAssessmentFunction;
import com.cts.cc.model.Assessment;
String line="";
list=new ArrayList<Assessment>();
while((line=br.readLine())!=null)
list.add(function.apply(line));
return list;
SkeletonValidator.java*
package com.cts.cc;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.sql.Connection;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.Period;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.cts.cc.model.Assessment;
public SkeletonValidator() {
Period.class };
testClass(assessmentClass, assessmentParams);
testClass(assessmentDAOClass, null);
testClass(funtionalClass, null);
testClass(databaseUtilClass, null);
testClass(fileUtilClass, null);
testFields(assessmentClass, assessmentFields);
try {
constructor.equals(constructor);
} catch (ClassNotFoundException e) {
+ "Use the correct package and class name as provided in the skeleton");
} catch (NoSuchMethodException e) {
+ "Do not change the given public constructor. " + "Verify it with the
skeleton");
} catch (SecurityException e) {
LOG.log(Level.SEVERE,
"There is an error in validating the " + className + ". " + "Please verify the
skeleton manually");
try {
classUnderTest.getDeclaredField(field);
} catch (ClassNotFoundException e) {
+ "Use the correct package and class name as provided in the skeleton");
} catch (NoSuchFieldException e) {
LOG.log(Level.SEVERE,
"You have changed one/more field(s). " + "Use the field name(s) as provided
in the skeleton");
} catch (SecurityException e) {
LOG.log(Level.SEVERE,
"There is an error in validating the " + className + ". " + "Please verify the
skeleton manually");
public void testMethods(String className, String methodName, Class[] paramTypes, Class returnType) {
try {
LOG.log(Level.SEVERE, " You have changed the " + "return type in '" + methodName
} catch (ClassNotFoundException e) {
+ "Use the correct package and class name as provided in the skeleton");
} catch (NoSuchMethodException e) {
} catch (SecurityException e) {
LOG.log(Level.SEVERE,
"There is an error in validating the " + className + ". " + "Please verify the
skeleton manually");
}
Main.java*
package com.cts.cc;
import java.util.List;
import com.cts.cc.dao.AssessmentDAO;
import com.cts.cc.model.Assessment;
import com.cts.cc.util.FileUtil;
new SkeletonValidator();
try {
dao.uploadAssessments(assessments);
assessment.printDetails();
} catch (Exception e) {
System.out.println(e);
}
Book Details
Main.java*
import java.util.Scanner;
if(string.length()==18)
int i1 = Integer.parseInt(substr1);
int i2 = Integer.parseInt(substr2);
//System.out.println(substr3);
int i3 = Integer.parseInt(substr3);
if(i3>=10)
if((substr4.charAt(0)>='A'&&substr4.charAt(0)<='Z')||(substr4.charAt(0)>='a'&&substr4.charAt(0)<='z'))
if((substr5.charAt(0)>='0'&&substr5.charAt(0)<='9')&&(substr5.charAt(1)>='0'&&substr5.charAt(1)<='9')&&
(substr5.charAt(2)>='0'&&substr5.charAt(2)<='9')&&(substr5.charAt(3)>='0'&&substr5.charAt(3)<='9')&&
(substr5.charAt(4)>='0'&&substr5.charAt(4)<='9'))
{
String substr6 = string.substring(12,18);
if(i1==101)
else if(i1==102)
else if(i1==103)
else
System.out.printf("\n");
else
System.out.printf("\n");
else
System.out.printf("\n");
}
}
else
System.out.printf("\n");
else
System.out.printf("\n");
else
System.out.printf("\n");
}
Find Membership Category
Member.java*
return memberId;
this.memberId = memberId;
return memberName;
this.memberName = memberName;
return category;
this.category = category;
super();
this.memberId = memberId;
this.memberName = memberName;
this.category = category;
}
}
ZeeShop.java*
import java.util.List;
super();
this.memberCategory = memberCategory;
this.memberList = memberList;
return memberCategory;
this.memberCategory = memberCategory;
}
public int getCount() {
return count;
this.count = count;
return memberList;
this.memberList = memberList;
synchronized(this)
for(Member m:memberList)
if(m.getCategory().equals(memberCategory))
count++;
}
}
Main.java*
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
int tot=sc.nextInt();
for(int i=0;i<str.length;i++)
str[i]=sc.next();
for(int i=0;i<m.length;i++)
String s[]=str[i].split(":");
m[i]=new Member(s[0],s[1],s[2]);
mList.add(m[i]);
int tot1=sc.nextInt();
for(int i=0;i<tot1;i++)
String s1=sc.next();
t1[i]=new ZEEShop(s1,mList);
t1[i].start();
//System.out.println(s1+" "+t1.getCount());
try {
Thread.currentThread().sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
for(ZEEShop s:t1)
System.out.println(s.getMemberCategory()+":"+s.getCount());
}
Go Hospitals
InPatient.java*
public InPatient(String patientId, String patientName, long mobileNumber, String gender, double roomRent) {
super(patientId,patientName,mobileNumber,gender);
this.roomRent=roomRent;
return roomRent;
this.roomRent = roomRent;
double bill_amount;
bill_amount=((this.roomRent*noOfDays)+medicinalBill);
return bill_amount;
OutPatient.java*
public OutPatient(String patientId, String patientName, long mobileNumber, String gender, double consultingFee)
{
super(patientId,patientName,mobileNumber,gender);
this.consultingFee=consultingFee;
return consultingFee;
this.consultingFee = consultingFee;
double bill_amount;
bill_amount=this.consultingFee+scanPay+medicinalBill;
return bill_amount;
Patient.java*
this.patientId = patientId;
this.patientName = patientName;
this.mobileNumber = mobileNumber;
this.gender = gender;
return patientId;
this.patientId = patientId;
return patientName;
this.patientName = patientName;
return mobileNumber;
this.mobileNumber = mobileNumber;
return gender;
this.gender = gender;
}
UserInterface.java*
import java.util.Scanner;
System.out.println("1.In Patient");
System.out.println("1.Out Patient");
int ch=read.nextInt();
System.out.println("Patient Id");
String id=read.nextLine();
System.out.println("Patient Name");
String name=read.nextLine();
read.nextLine();
System.out.println("Phone Number");
long num=read.nextLong();
System.out.println("Gender");
String gen=read.next();
if(ch==1){
System.out.println("Room Rent");
double rent=read.nextDouble();
System.out.println("Medicinal Bill");
double bill=read.nextDouble();
int days=read.nextInt();
else{
System.out.println("Consultancy Fee");
double fee=read.nextDouble();
System.out.println("Medicinal Bill");
double medbill=read.nextDouble();
System.out.println("Scan Pay");
double pay=read.nextDouble();
}
Grade Calculation
GradeCalculator.java*
return studName;
this.studName = studName;
return result;
this.result = result;
return marks;
this.marks = marks;
}
public GradeCalculator(String studName, int[] marks){
this.studName = studName;
this.marks = marks;
int sum = 0;
for(int i = 0;i<score.length;i++)
sum = sum+score[i];
if((400<=sum)&&(sum<=500))
System.out.println(getStudName()+":"+'A');
if((300<=sum)&&(sum<=399))
System.out.println(getStudName()+":"+'B');
if((200<=sum)&&(sum<=299))
System.out.println(getStudName()+":"+'C');
if(sum<200)
System.out.println(getStudName()+":"+'E');
Main.java*
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.InputStreamReader;
int th = Integer.parseInt(br.readLine());
str = br.readLine();
details[i]=str;
int k = 0;
arr[k++] = Integer.parseInt(sp[j]);
obj.start();
try{
Thread.sleep(1000);
catch(Exception e)
System.out.println(e);
}
Passanger Amenity
Main.java*
import java.util.Scanner;
int num,n,i,count1=0,count2=0,y;
char alpha,ch;
String n1,n2;
n=sc.nextInt();
if(n<=0){
System.exit(0);
for(i=0;i<n;i++,count1=0,count2=0){
arr1[i] =sc.next();
arr2[i]= sc.next();
num =Integer.parseInt(arr2[i].substring(1,(arr2[i].length())));
alpha= arr2[i].charAt(0);
count2++;
for(ch=65;ch<84;ch++){
if(ch==alpha){
count1++;
if(count1==0){
System.out.println(""+alpha+" is invalid coach");
System.exit(0);
if(count2==0){
System.exit(0);
for(i=0;i<n;i++){
for(int j=i+1;j<n;j++){
if(arr2[i].charAt(0)==arr2[j].charAt(0)){
if((Integer.parseInt(arr2[i].substring(1,(arr2[i].length()))))<(Integer.parseInt(arr2[j].substring(1,arr2[j].length())))){
n1=arr1[i];
n2=arr2[i];
arr1[i]=arr1[j];
arr2[i]=arr2[j];
arr1[j]=n1;
arr2[j]=n2;
else
if(arr2[i].charAt(0)<arr2[j].charAt(0))
n1=arr1[i];
n2=arr2[i];
arr1[i]=arr1[j];
arr2[i]=arr2[j];
arr1[j]=n1;
arr2[j]=n2;
}
for(i=0;i<n;i++){
String a=arr1[i].toUpperCase();
String b=arr2[i];
System.out.print(a+" "+b);
System.out.println("");
}
Perform Calculation
Calculate.java*
Calculator.java*
import java.util.Scanner;
int a = sc.nextInt();
int b= sc.nextInt();
return Perform_calculation;
return Perform_calculation;
return Perform_calculation;
}
float c = (float)a;
float d = (float)b;
return (c/d);
};
return Perform_calculation;
}
Query DataSet
Query.java*
@Override
String g="";
g+=("Theatre id : "+primaryDataSet.getTheatreId()+"\n");
g+=("Location :"+primaryDataSet.getLocation()+"\n");
g+=("Theatre id : "+secondaryDataSet.getTheatreId()+"\n");
g+=("Location :"+secondaryDataSet.getLocation()+"\n");
g+=("Query id : "+queryId+"\n");
return g;
}
public class DataSet{
return ticketCost;
ticketCost=a;
return noOfScreen;
noOfScreen=a;
return location;
location=a;
}
return theatreName;
theatreName=a;
return theatreId;
theatreId=a;
this.secondaryDataSet=pD;
return this.secondaryDataSet;
this.primaryDataSet=pD;
}
public DataSet getPrimaryDataSet()
return this.primaryDataSet;
this.queryId=queryId;
this.queryCategory=queryCategory;
return this.queryId;
return this.queryCategory;
TestApplication.java*
import java.util.*;
pd.setTheatreName(sc.nextLine());
pd.setLocation(sc.nextLine());
pd.setNoOfScreen(sc.nextInt());
pd.setTicketCost(sc.nextDouble());
String id2=sc.next();
// System.out.println(id2);
sd.setTheatreId(id2);
sc.nextLine();
sd.setTheatreName(sc.nextLine());
String gll=sc.nextLine();
sd.setLocation(gll);
// System.out.println(gll);
// String pp=sc.nextLine();
// System.out.println(pp);
sd.setNoOfScreen(sc.nextInt());
sd.setTicketCost(sc.nextDouble());
sc.nextLine();
q.setQueryId(sc.nextLine());
q.setQueryCategory(sc.nextLine());
q.setSecondaryDataSet(sd);
q.setPrimaryDataSet(pd);
System.out.println(q.toString());
}
Retrive Flight Based On Source And Destination
Flight.java*
return flightId;
this.flightId = flightId;
return source;
this.source = source;
return destination;
this.destination = destination;
return noOfSeats;
this.noOfSeats = noOfSeats;
}
public double getFlightFare() {
return flightFare;
this.flightFare = flightFare;
super();
this.flightId = flightId;
this.source = source;
this.destination = destination;
this.noOfSeats = noOfSeats;
this.flightFare = flightFare;
FlightManagement.java*
import java.util.ArrayList;
import java.sql.*;
try{
String query="SELECT * FROM flight WHERE source= '" + source + "' AND destination= '" + destination + "' ";
Statement st=con.createStatement();
while(rst.next()){
String src=rst.getString(2);
String dst=rst.getString(3);
int noofseats=rst.getInt(4);
double flightfare=rst.getDouble(5);
e.printStackTrace();
return flightList;
DB.java*
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
public class DB {
try{
props.load(fis);
Class.forName(props.getProperty("DB_DRIVER_CLASS"));
con =
DriverManager.getConnection(props.getProperty("DB_URL"),props.getProperty("DB_USERNAME"),props.getPropert
y("DB_PASSWORD"));
catch(IOException e){
e.printStackTrace();
return con;
Main.java*
import java.util.Scanner;
import java.util.ArrayList;
String source=sc.next();
String destination=sc.next();
FlightManagementSystem fms= new FlightManagementSystem();
ArrayList<Flight> flightList=fms.viewFlightBySourceDestination(source,destination);
if(flightList.isEmpty()){
return;
}
Silver Health Plan Insurance
FamilyInsurancePolicy.java
public FamilyInsurancePolicy(String clientName, String policyId, int age, long mobileNumber, String emailId) {
int count=0;
if(policyId.contains("FAMILY"));
count++;
char ch[]=policyId.toCharArray();
for(int i=6;i<9;i++)
count++;
if(count==4)
return true;
else
return false;
double amount=0;
amount=2500*months*no_of_members;
amount=5000*months*no_of_members;
else if (age>=60)
amount=10000*months*no_of_members;
return amount;
IndividualInsurancePolicy.java*
public IndividualInsurancePolicy(String clientName, String policyId, int age, long mobileNumber, String
emailId) {
int count=0;
if(policyId.contains("SINGLE"));
count++;
char ch[]=policyId.toCharArray();
for(int i=6;i<9;i++)
count++;
if(count==4)
return true;
else
return false;
double amount=0;
if(age>=5 && age<=25)
amount=2500*months;
amount=5000*months;
else if (age>=60)
amount=10000*months;
return amount;
InsurancePolicies.java*
return clientName;
this.clientName = clientName;
return policyId;
this.policyId = policyId;
return age;
return mobileNumber;
this.mobileNumber = mobileNumber;
return emailId;
this.emailId = emailId;
public InsurancePolicies(String clientName, String policyId, int age, long mobileNumber, String emailId) {
super();
this.clientName = clientName;
this.policyId = policyId;
this.age = age;
this.mobileNumber = mobileNumber;
this.emailId = emailId;
SeniorCitizenPolicy.java*
public SeniorCitizenPolicy(String clientName, String policyId, int age, long mobileNumber, String emailId) {
int count=0;
if(policyId.contains("SENIOR"));
count++;
char ch[]=policyId.toCharArray();
for(int i=6;i<9;i++)
count++;
if(count==4)
return true;
else
return false;
double amount=0;
amount=0;
else if (age>=60)
amount=10000*months*no_of_members;
return amount;
UserInterface.java*
import java.util.Scanner;
{
Scanner sc=new Scanner(System.in);
String name=sc.next();
String id=sc.next();
int age=sc.nextInt();
long mnum=sc.nextLong();
String email=sc.next();
int month=sc.nextInt();
double amount=0;
if(id.contains("SINGLE"))
if(g.validatePolicyId())
//System.out.println(g.validatePolicyId());
amount=g.calculateInsuranceAmount(month);
System.out.println("Name :"+name);
System.out.println("Email Id :"+email);
else
}
else if(id.contains("FAMILY"))
if(g.validatePolicyId())
int num=sc.nextInt();
amount=g.calculateInsuranceAmount(month,num);
System.out.println("Name :"+name);
System.out.println("Email Id :"+email);
else
else if(id.contains("SENIOR"))
if(g.validatePolicyId())
int num=sc.nextInt();
amount=g.calculateInsuranceAmount(month,num);
System.out.println("Name :"+name);
System.out.println("Email Id :"+email);
else
}
else
}
Travel Request System
TraveRequestDao.java*
package com.cts.travelrequest.dao;
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.*;
import java.util.*;
//import java.util.Properties;
import com.cts.travelrequest.vo.TravelRequest;
class DB{
//ENSURE YOU DON'T CHANGE THE BELOW CODE WHEN YOU SUBMIT
try{
props.load(fis);
Class.forName(props.getProperty("DB_DRIVER_CLASS"));
catch(IOException e){
e.printStackTrace();
return con;
/**
* @return list
*/
try{
Connection con=DB.getConnection();
PreparedStatement ps=con.prepareStatement(query);
ps.setString(1,sourceCity);
ps.setString(2,destinationCity);
ResultSet rs=ps.executeQuery();
while(rs.next()){
String tid=rs.getString("travelReqId");
java.sql.Date date=rs.getDate("travelDate");
String apstat=rs.getString("approvalStatus");
String sour=rs.getString("sourceCity");
String des=rs.getString("destinationCity");
double cost=rs.getDouble("travelCost");
catch(ClassNotFoundException e){
e.printStackTrace();
catch(SQLException e ){
e.printStackTrace();
/**
* @return list
*/
double amount=0;
try{
Connection con=DB.getConnection();
PreparedStatement ps1=con.prepareStatement(query);
ps1.setString(1,approvalStatus);
ResultSet rs1=ps1.executeQuery();
while(rs1.next()){
amount+=rs1.getDouble("travelCost");
catch(ClassNotFoundException e){
e.printStackTrace();
}
catch(SQLException e){
e.printStackTrace();
TravelRequestService.java*
package com.cts.travelrequest.service;
import java.util.List;
import com.cts.travelrequest.dao.TravelRequestDao;
import com.cts.travelrequest.vo.TravelRequest;
/**
* @return status
*/
if(approvalStatus.equalsIgnoreCase("Approved")||approvalStatus.equalsIgnoreCase("Pending")){
return "valid";
/**
* @return status
*/
if(!sourceCity.equalsIgnoreCase(destinationCity)){
if(sourceCity.equalsIgnoreCase("Pune")|| sourceCity.equalsIgnoreCase("Mumbai")||
sourceCity.equalsIgnoreCase("Chennai")|| sourceCity.equalsIgnoreCase("Bangalore")||
sourceCity.equalsIgnoreCase("Hydrabad")){
if(destinationCity.equalsIgnoreCase("Pune")||
destinationCity.equalsIgnoreCase("Mumbai")||destinationCity.equalsIgnoreCase("Chennai")||
destinationCity.equalsIgnoreCase("Bangalore")|| destinationCity.equalsIgnoreCase("Hydrabad")){
return "valid";
else{
return "invalid";
else{
return "invalid";
else{
return "invalid";
/**
* @return listOfTravelRequest
*/
if(this.validateSourceAndDestination(sourceCity,destinationCity).contentEquals("valid")){
return TravelRequestDao.getTravelDetails(sourceCity,destinationCity);
else{
return null;
}
}
/**
* @return totalCost
*/
if(this.validateApprovalStatus(approvalStatus).equals("valid")){
return TravelRequestDao.calculateTotalTravelCost(approvalStatus);
else{
return -1;
SkeletonValidator.java*
package com.cts.travelrequest.skeletonvalidator;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* @author t-aarti3
* This class is used to verify if the Code Skeleton is intact and not
* */
public SkeletonValidator() {
validateClassName("com.cts.travelrequest.service.TravelRequestService");
validateClassName("com.cts.travelrequest.vo.TravelRequest");
validateMethodSignature(
"validateApprovalStatus:java.lang.String,validateSourceAndDestination:java.lang.String,getTravelDetails:java
.util.List,calculateTotalTravelCost:double",
"com.cts.travelrequest.service.TravelRequestService");
try {
Class.forName(className);
iscorrect = true;
} catch (ClassNotFoundException e) {
LOG.log(Level.SEVERE, "You have changed either the " + "class name/package. Use the
correct package "
} catch (Exception e) {
LOG.log(Level.SEVERE,
"There is an error in validating the " + "Class Name. Please manually verify
that the "
return iscorrect;
try {
String[] methodSignature;
methodSignature = singleMethod.split(":");
methodName = methodSignature[0];
returnType = methodSignature[1];
cls = Class.forName(className);
if (methodName.equals(findMethod.getName())) {
foundMethod = true;
if (!(findMethod.getReturnType().getName().equals(returnType))) {
errorFlag = true;
} else {
if (!foundMethod) {
errorFlag = true;
+ ". Do not change the " + "given public method name. " +
"Verify it with the skeleton");
}
if (!errorFlag) {
} catch (Exception e) {
LOG.log(Level.SEVERE,
" There is an error in validating the " + "method structure. Please manually
verify that the "
TravelRequest.java*
package com.cts.travelrequest.vo;
import java.util.Date;
// member variables
public TravelRequest() {
super();
// parameterized constructor
super();
this.travelReqId = travelReqId;
this.travelDate = travelDate;
this.approvalStatus = approvalStatus;
this.sourceCity = sourceCity;
this.destinationCity = destinationCity;
this.travelCost = travelCost;
// setter, getter
/**
*/
return travelReqId;
/**
* @param travelReqId
*/
this.travelReqId = travelReqId;
/**
*/
return travelDate;
/**
* @param travelDate
*/
this.travelDate = travelDate;
/**
*/
return approvalStatus;
/**
* @param approvalStatus
*/
this.approvalStatus = approvalStatus;
/**
*/
return sourceCity;
/**
* @param sourceCity
*/
this.sourceCity = sourceCity;
/**
return destinationCity;
/**
* @param destinationCity
*/
this.destinationCity = destinationCity;
/**
*/
return travelCost;
/**
* @param travelCost
*/
this.travelCost = travelCost;
Main.java*
package com.cts.travelrequest.main;
import java.sql.*;
import java.util.*;
import java.text.SimpleDateFormat;
import com.cts.travelrequest.service.TravelRequestService;
import com.cts.travelrequest.skeletonvalidator.SkeletonValidator;
import com.cts.travelrequest.vo.TravelRequest;
new SkeletonValidator();
String sourceCity=sc.next();
String destinationCity=sc.next();
String status=sc.next();
if(service.validateSourceAndDestination(sourceCity,destinationCity).equals("valid")){
if(ltr.isEmpty()){
System.out.println("No travel request raised for given source and destination cities");
else{
for(TravelRequest t:ltr){
String d=sd.format(t.getTravelDate());
}
else{
if(service.validateApprovalStatus(status).contentEquals("valid")){
System.out.println(service.calculateTotalTravelCost(status));
else{