REGISTERED CUSTOMER(100 POINTS)
import [Link].*;
class Address
String l1,l2,city,pin;
Address(String a,String b,String c,String d)
l1=a;
l2=b;
city=c;
pin=d;
void setl1(String x)
this.l1=x;
String getl1()
return this.l1;
void setl2(String x)
this.l2=x;
String getl2()
return this.l2;
}
void setcity(String x)
[Link]=x;
String getcity()
return [Link];
void setpin(String x)
[Link]=x;
String getpin()
return [Link];
class Customer
String custid, custname;
Address address;
Customer(String custid, String custname, Address address)
[Link]=custid;
[Link]=custname;
[Link]=address;
String getcustid()
return [Link];
}
String getcustname()
return [Link];
String getl1()
return [Link].l1;
String getl2()
return [Link].l2;
String getcity()
return [Link];
String getpin()
return [Link];
class RegCustomer extends Customer
double fees;
RegCustomer(String custid, String custname, Address address,double fees)
super(custid,custname,address);
[Link]=fees;
}
void setcustid(String x)
[Link]=x;
void setcustname(String x)
[Link]=x;
void setfees(double x)
[Link]=x;
void setl1(String x)
[Link].l1=x;
void setl2(String x)
[Link].l2=x;
void setcity(String x)
[Link]=x;
void setpin(String x)
[Link]=x;
double getfees()
return [Link];
}
void display()
[Link]("Customer Id :"+[Link]+"\nCustomer Name
:"+[Link]+"\nCustomer fees :"+[Link]);
[Link]("Address 1 :"+[Link].l1+"\nAddress 2
:"+[Link].l2+"\nCity :"+[Link]);
[Link]("Pin :"+[Link]);
public class source
public static void main(String args[])
Scanner sc=new Scanner([Link]);
String l1=[Link]();
String l2=[Link]();
String city=[Link]();
String pin=[Link]();
Address a=new Address(l1,l2,city,pin);
String custId=[Link]();
String custName=[Link]();
double fees=[Link]();
RegCustomer ob=new RegCustomer(custId,custName,a,fees);
[Link]();
}
BEAUTY PARLOUR(100)
import [Link].*;
import [Link].*;
class Customers
String name;
public String getName(){
return name;
public void setName(String name) {
[Link] = name;
public boolean isMember() {
return member;
public void setMember(boolean member) {
[Link] = member;
public String getMembertype() {
return membertype;
public void setMembertype(String membertype) {
[Link] = membertype;
boolean member;
String membertype;
Customers(String name)
[Link]=name;
@Override
public String toString() {
return "Customer [name=" + name + ", member=" + member
+ ", membertype=" + membertype + "]";
class Visit
String name;
Customers cust;
double serviceExpense;
double productExpense;
double totalExpense;
Visit(Customers cust)
[Link]=cust;
public String getName()
return [Link]();
public double getServiceExpense()
return serviceExpense;
}
public void setServiceExpense(double serviceExpense)
[Link]=serviceExpense;
public double getProductExpense() {
return productExpense;
public void setProductExpense(double productExpense) {
[Link] = productExpense;
public double totalExpense()
double dis=0;
double dis1=0;
//[Link]("Mtype in tot exp:"+[Link]());
if([Link]().equals("null"))
return serviceExpense+productExpense;
else
dis= serviceExpense *
[Link]([Link]());
dis1=productExpense*[Link];
double prodiscount=productExpense-dis1;
double totalExpense1=serviceExpense-dis;
//[Link]("After Discount on service:"+totalExpense1);
[Link](totalExpense1);
double totalExpense2=productExpense-dis1;
//[Link]("After Discount on product:"+totalExpense2);
[Link](totalExpense2);
//return totalExpense=serviceExpense-dis;
//return totalExpense=serviceExpense+prodiscount;
return totalExpense=totalExpense1+totalExpense2;
@Override
/*public String toString() {
return "Visit [ cust=" + cust + ", serviceExpense="
+ serviceExpense + ", productExpense=" + productExpense
+" Discount
Rate="+[Link]([Link]())+"]";
}*/
public String toString() {
return "[Customer Name:"+cust+"Service
Expense:"+serviceExpense+"Discount:"+[Link](cus
[Link]())+"]Product Discout:"+[Link]+"Product
Discount:"+[Link]([Link]());
class DiscountRate
static double premiumService=0.2;
static double goldService=0.15;
static double silverService=0.1;
static double prodsilverService=0.1;
static double prodgoldService=0.1;
static double prodpremiumService=0.1;
static double proddiscount=0.1;
public static double getServiceDiscountRate(String service)
//[Link]("Mtype is:"+service);
if([Link]("Premium"))
return premiumService;
else if([Link]("Gold"))
return goldService;
else if([Link]("Silver"))
return silverService;
else if([Link]("null"))
[Link]("Not Qualified for any Discounts on
Service/Products");
}
return 0;
public static double getProductDiscountRate(String service)
if([Link]("Premium"))
return prodpremiumService;
else if([Link]("Gold"))
return prodgoldService;
else if([Link]("Silver"))
return prodsilverService;
else
return 0;
// Class name should be "Source",
// otherwise solution won't be accepted
public class Source {
public static void main(String[] args) {
Scanner s=new Scanner([Link]);
//[Link]("Enter Customer Name");
String name=[Link]();
//[Link]("Enter true for membership or false for no
membership");
boolean b=[Link]();
//[Link]("membership Type(Gold/Silver/Premium)");
String mtype=[Link]();
//[Link]("Enter Service Expense");
double serexp=[Link]();
//[Link]("Enter Product Expense");
double prodexp=[Link]();
Customers c=new Customers(name);
Visit v=new Visit(c);
[Link](b);
[Link](mtype);
[Link](serexp);
[Link](prodexp);
[Link]([Link]());
[Link]([Link]());
[Link]([Link]());
[Link]([Link]());
[Link]([Link]());
[Link]([Link]());
}
TWO PERSON(100)
Scanner s=new Scanner([Link]);
String name=[Link]();
int a=[Link]();
String g=[Link]();
String name1=[Link]();
int a1=[Link]();
String g1=[Link]();
if([Link](name1) && a==a1 && [Link](g1))
[Link]("The persons are same...");
else
[Link]("The persons are different...");
}
PHONE BOOK(not sure but only solution)
public void setPhoneNumber(long phoneNumber) throws
InvalidPhoneNumberExcception {
String phone = [Link](phoneNumber);
int mobileChecker = [Link]("^[6-9][0-9]{9}$", phone) ? 1 : -1;
if (mobileChecker == 1) {
[Link] = phoneNumber;
} else {
throw new InvalidPhoneNumberExcception();
public Address getAddress() {
return address;
public void setAddress(Address address) {
[Link] = address;
@Override
public String toString() {
return [Link](
"Customer [userId=%s, emailId=%s, password=%s, firstName=%s,
lastName=%s, city=%s, gender=%s, phoneNumber=%s, address=%s]",
userId, emailId, password, firstName, lastName, city, gender,
phoneNumber, address);
class Address {
private String city;
private String state;
private int zip;
private String country;
Address() {
public Address(String city, String state, int zip, String country) {
[Link] = city;
[Link] = state;
[Link] = zip;
[Link] = country;
public String getCity() {
return city;
public void setCity(String city) {
[Link] = city;
public String getState() {
return state;
public void setState(String state) {
[Link] = state;
public int getZip() {
return zip;
public void setZip(int zip) {
[Link] = zip;
public String getCountry() {
return country;
public void setCountry(String country) {
[Link] = country;
@Override
public String toString() {
return [Link]("Address [city=%s, state=%s, zip=%s, country=%s]",
city, state, zip, country);
public class Source {
public static void main(String[] args) throws InvalidNameException,
InvalidPhoneNumberExcception {
}
DATE MONTH EXCEPTION(100)
import [Link];
class MonthException extends Exception{
public MonthException(String message){
super(message);
class DayException extends Exception{
public DayException(String message){
super(message);
class YearException extends Exception{
public YearException(String message){
super(message);
public class TestException{
public static void main(String[] args) {
int monthnum;
int monthDays=0;
String monthName="";
String date="";
Scanner input=new Scanner([Link]);
[Link]("Please enter a date in this format:
Month/Day/Year.");
date=[Link]();
String[] pars=[Link]("/");
int month=[Link](pars[0]);
int day=[Link](pars[1]);
int year=[Link](pars[2]);
switch(month){
case 1:
monthName="January";
monthDays=31;
case 2:
monthName="February";
monthDays=28;
case 3:
monthName="March";
monthDays=31;
case 4:
monthName="April";
monthDays=30;
case 5:
monthName="May";
monthDays=31;
case 6:
monthName="June";
monthDays=30;
case 7:
monthName="July";
monthDays=31;
case 8:
monthName="August";
monthDays=31;
case 9:
monthName="September";
monthDays=30;
case 10:
monthName="October";
monthDays=31;
case 11:
monthName="November";
monthDays=30;
case 12:
monthName="December";
monthDays=31;
default:
[Link]("Not valid.");
while(true){
try{
if(month<1||month>12){
throw new MonthException("The month must be numbers 1-12.");
else{
break;
catch(MonthException e){
[Link]("Please enter a valid month: ");
month=[Link]();
continue;
while(true){
try{
if(day<1||day>monthDays){
throw new DayException("That day does not exist in this month.");
else{
break;
catch(DayException e){
[Link]("Please enter a valid day: ");
day=[Link]();
continue;
while(true){
try{
if(year<=1000||year>=3000){
throw new YearException("The year must be between 1000 and 3000.");
else{
break;
catch(YearException e){
[Link]("Please enter a valid year: ");
year=[Link]();
continue;
[Link]("The date conversion is: " + monthName+ " " + day + ",
" + year);
}
Rail Compartment 100
import [Link];
import [Link];
public class Main
public static void main(String[] args) {
Scanner s=new Scanner([Link]);
int i=0;
int arr []=new int[10];
int p=[Link]();
Random rand = new Random();
int upperbound = 4;
int int_random = [Link](upperbound);
int_random=int_random+1;
if(p==1)
FirstClass a= new FirstClass();
for(i=0;i<10;i++)
[Link]();
else if(p==2)
General a= new General();
for(i=0;i<10;i++)
[Link]();
else if(p==3)
{
Ladies a= new Ladies();
for(i=0;i<10;i++)
[Link]();
else
Luggage a= new Luggage();
for(i=0;i<10;i++)
[Link]();
abstract class Compartment
abstract void notice();
class FirstClass extends Compartment
public void notice()
[Link]("FirstClass Compartment");
class Ladies extends Compartment
public void notice()
[Link]("Ladies Compartment");
}
}
class General extends Compartment
public void notice()
[Link]("General Compartment");
class Luggage extends Compartment
public void notice()
[Link]("Luggage Compartment");