Showing posts with label code saviour trend. Show all posts
Showing posts with label code saviour trend. Show all posts

Sunday, 20 November 2022

Association - Exercise 1

 

Association - Exercise 1


You need to develop an application for cab service providers by implementing the classes based on the class diagram and description given below.    Note: Driver class is provided to you.  Method Description  CabServiceProvider  CabServiceProvider(String cabServiceName, int totalCabs)  Initialize all the instance variables appropriately with the values passed to the constructor. calculateRewardPrice(Driver driver)  Calculate and return the bonus of the driver based on the below table. If averageRating of the driver is less than 4, return the bonus as 0.                  In case of any invalid value, return the bonus as 0.  Note: Round off the bonus to 2 decimal digits.  Implement the appropriate getter and setter methods.  Perform case-sensitive comparison wherever applicable.  Test the functionalities using the provided Tester class.      Sample Input and Output  Input  For CabServiceProvider object cabServiceProvider1 with cabServiceName = Halo and totalCabs = 50  Driver object - driver1    Driver object - driver2    Driver object - driver3    Output,coding savior,infosys assignment quiz and lex genrric ansewer,infosys generic java program, code answer,code saviour,code monk,coding bar,code solution for infosys  assignmenet,code saviour trend



class CabServiceProvider{
private static final String String=null;
private String cabServiceName;
private int totalCabs;
public CabServiceProvider(String cabServiceName,int totalCabs){
this.cabServiceName=cabServiceName;
this.totalCabs=totalCabs;
}
public String getCabServiceName(){
return cabServiceName;
}
public void setCabServiceName(String cabServiceName){
this.cabServiceName=cabServiceName;
}
public int getTotalCabs(){
return totalCabs;
}
public  void setTotalCabs(int totalCabs){
this.totalCabs=totalCabs;
}
public double calculateRewardPrice(Driver driver){
double bonus=0.0;
double rewardAmount=0.0;
if(cabServiceName.equals("Halo")){
if(driver.getAverageRating()>=4.5&&driver.getAverageRating()<=5){
rewardAmount=10*driver.getAverageRating();
}
else if(driver.getAverageRating()>=4&&driver.getAverageRating()<4.5){
rewardAmount=5*driver.getAverageRating();
}
else{
rewardAmount=0.0;
}
}
else if(cabServiceName.equals("Aber")){
if(driver.getAverageRating()>=4.5&&driver.getAverageRating()<=5){
rewardAmount=8*driver.getAverageRating();
}
else if(driver.getAverageRating()>=4&&driver.getAverageRating()<4.5){
rewardAmount=3*driver.getAverageRating();
}
else{
rewardAmount=0.0;
}
}
else{
rewardAmount=0.0;
}
bonus=Math.round(rewardAmount*100.0)/100.0;
return bonus;
}
}

class Driver {
   
    private String driverName;
    private float averageRating;
   
    public Driver(String driverName, float averageRating){
        this.driverName=driverName;
        this.averageRating=averageRating;
    }
   
    public String getDriverName(){
        return this.driverName;
    }
   
    public void setDriverName(String driverName){
        this.driverName=driverName;
    }
   
    public float getAverageRating(){
        return this.averageRating;
    }
   
    public void setAverageRating(float averageRating){
        this.averageRating=averageRating;
    }

    //DO NOT MODIFY THE METHOD
    //Your exercise might not be verified if the below method is modified
    public String toString(){
        return "Driver\ndriverName: "+this.driverName+"\naverageRating: "+this.averageRating;
    }
}

class Tester {
   
    public static void main(String args[]){
        CabServiceProvider cabServiceProvider1 = new CabServiceProvider("Halo", 50);

        Driver driver1 = new Driver("Luke", 4.8f);
        Driver driver2 = new Driver("Mark", 4.2f);
        Driver driver3 = new Driver("David", 3.9f);
       
        Driver[] driversList = { driver1, driver2, driver3 };
        for (Driver driver : driversList) {
            System.out.println("Driver Name: "+driver.getDriverName());
            double bonus = cabServiceProvider1.calculateRewardPrice(driver);
            if (bonus>0)
                System.out.println("Bonus: $"+bonus+"\n");
            else
                System.out.println("Sorry, bonus is not available!");
        }
       
        //Create more objects of CabServiceProvider and Driver classes for testing your code
    }
}

You need to develop an application for cab service providers by implementing the classes based on the class diagram and description given below.    Note: Driver class is provided to you.  Method Description  CabServiceProvider  CabServiceProvider(String cabServiceName, int totalCabs)  Initialize all the instance variables appropriately with the values passed to the constructor. calculateRewardPrice(Driver driver)  Calculate and return the bonus of the driver based on the below table. If averageRating of the driver is less than 4, return the bonus as 0.                  In case of any invalid value, return the bonus as 0.  Note: Round off the bonus to 2 decimal digits.  Implement the appropriate getter and setter methods.  Perform case-sensitive comparison wherever applicable.  Test the functionalities using the provided Tester class.      Sample Input and Output  Input  For CabServiceProvider object cabServiceProvider1 with cabServiceName = Halo and totalCabs = 50  Driver object - driver1    Driver object - driver2    Driver object - driver3    Output


Static - Exercise 1 infosys

 

Static - Exercise 1

coding savior,infosys assignment quiz and lex genrric ansewer,infosys generic java program, code answer,code saviour,code monk,coding bar,code solution for infosys  assignmenet,code saviour trend , Implement the class Bill based on the class diagram and description given below.    Method Description  Bill(String paymentMode)  Initialize the paymentMode instance variable with the value passed to the parameter.   Generate the billId using counter. The value of billId should start from 'B9001' and the numerical part should be incremented by 1 for the subsequent values. Initialize the counter in static block.  Implement the appropriate getter and setter methods.     Test the functionalities using the provided Tester class. Create two or more Bill objects and validate that the billId is being generated properly.  Sample Input and Output  For constructor  Input  For first Bill object    For second Bill object    Output





























class Bill{
private static int counter;
private String billId;
private String paymentMode;
static{
counter=9000;
}
public Bill(String paymentMode){
this.paymentMode=paymentMode;
billId="B"+ ++counter;
}
public static int getCounter(){
return counter;
}
public String getBillId(){
return billId;
}
public  void setBillId(String billId){
this.billId=billId;
}
public String getPaymentMode(){
return paymentMode;
}
public void setPaymentMode(String paymentMode){
this.paymentMode=paymentMode;
}

}

class Tester {
    public static void main(String[] args) {

        Bill bill1 = new Bill("DebitCard");
        Bill bill2 = new Bill("PayPal");
        Bill bill3=new Bill("CreditCard");
        Bill bill4=new Bill("PayTm");
        Bill bill5=new Bill("GooglePay");
       
        //Create more objects and add them to the bills array for testing your code
             
        Bill[] bills = { bill1, bill2, bill3, bill4, bill5};
             
        for (Bill bill : bills) {
            System.out.println("Bill Details");
            System.out.println("Bill Id: " + bill.getBillId());
            System.out.println("Payment method: " + bill.getPaymentMode());
            System.out.println();
       }
    }
}
Bill Details Bill Id: B9001 Payment method: DebitCard  Bill Details Bill Id: B9002 Payment method: PayPal  Bill Details Bill Id: B9003 Payment method: CreditCard  Bill Details Bill Id: B9004 Payment method: PayTm  Bill Details Bill Id: B9005 Payment method: GooglePay





Association - Exercise 1

 Association - Exercise 1


coding savior,infosys assignment quiz and lex genrric ansewer,infosys generic java program, code answer,code saviour,code monk,coding bar,code solution for infosys  assignmenet,code saviour trend , You need to develop an application for cab service providers by implementing the classes based on the class diagram and description given below.    Note: Driver class is provided to you.  Method Description  CabServiceProvider  CabServiceProvider(String cabServiceName, int totalCabs)  Initialize all the instance variables appropriately with the values passed to the constructor. calculateRewardPrice(Driver driver)  Calculate and return the bonus of the driver based on the below table. If averageRating of the driver is less than 4, return the bonus as 0.                  In case of any invalid value, return the bonus as 0.  Note: Round off the bonus to 2 decimal digits.  Implement the appropriate getter and setter methods.  Perform case-sensitive comparison wherever applicable.  Test the functionalities using the provided Tester class.      Sample Input and Output  Input  For CabServiceProvider object cabServiceProvider1 with cabServiceName = Halo and totalCabs = 50  Driver object - driver1    Driver object - driver2    Driver object - driver3    Output





























class CabServiceProvider{
private static final String String=null;
private String cabServiceName;
private int totalCabs;
public CabServiceProvider(String cabServiceName,int totalCabs){
this.cabServiceName=cabServiceName;
this.totalCabs=totalCabs;
}
public String getCabServiceName(){
return cabServiceName;
}
public void setCabServiceName(String cabServiceName){
this.cabServiceName=cabServiceName;
}
public int getTotalCabs(){
return totalCabs;
}
public  void setTotalCabs(int totalCabs){
this.totalCabs=totalCabs;
}
public double calculateRewardPrice(Driver driver){
double bonus=0.0;
double rewardAmount=0.0;
if(cabServiceName.equals("Halo")){
if(driver.getAverageRating()>=4.5&&driver.getAverageRating()<=5){
rewardAmount=10*driver.getAverageRating();
}
else if(driver.getAverageRating()>=4&&driver.getAverageRating()<4.5){
rewardAmount=5*driver.getAverageRating();
}
else{
rewardAmount=0.0;
}
}
else if(cabServiceName.equals("Aber")){
if(driver.getAverageRating()>=4.5&&driver.getAverageRating()<=5){
rewardAmount=8*driver.getAverageRating();
}
else if(driver.getAverageRating()>=4&&driver.getAverageRating()<4.5){
rewardAmount=3*driver.getAverageRating();
}
else{
rewardAmount=0.0;
}
}
else{
rewardAmount=0.0;
}
bonus=Math.round(rewardAmount*100.0)/100.0;
return bonus;
}
}

class Driver {
   
    private String driverName;
    private float averageRating;
   
    public Driver(String driverName, float averageRating){
        this.driverName=driverName;
        this.averageRating=averageRating;
    }
   
    public String getDriverName(){
        return this.driverName;
    }
   
    public void setDriverName(String driverName){
        this.driverName=driverName;
    }
   
    public float getAverageRating(){
        return this.averageRating;
    }
   
    public void setAverageRating(float averageRating){
        this.averageRating=averageRating;
    }

    //DO NOT MODIFY THE METHOD
    //Your exercise might not be verified if the below method is modified
    public String toString(){
        return "Driver\ndriverName: "+this.driverName+"\naverageRating: "+this.averageRating;
    }
}

class Tester {
   
    public static void main(String args[]){
        CabServiceProvider cabServiceProvider1 = new CabServiceProvider("Halo", 50);

        Driver driver1 = new Driver("Luke", 4.8f);
        Driver driver2 = new Driver("Mark", 4.2f);
        Driver driver3 = new Driver("David", 3.9f);
       
        Driver[] driversList = { driver1, driver2, driver3 };
        for (Driver driver : driversList) {
            System.out.println("Driver Name: "+driver.getDriverName());
            double bonus = cabServiceProvider1.calculateRewardPrice(driver);
            if (bonus>0)
                System.out.println("Bonus: $"+bonus+"\n");
            else
                System.out.println("Sorry, bonus is not available!");
        }
       
        //Create more objects of CabServiceProvider and Driver classes for testing your code
    }
}

coding savior,infosys assignment quiz and lex genrric ansewer,infosys generic java program, code answer,code saviour,code monk,coding bar,code solution for infosys  assignmenet,code saviour trend , You need to develop an application for cab service providers by implementing the classes based on the class diagram and description given below.    Note: Driver class is provided to you.  Method Description  CabServiceProvider  CabServiceProvider(String cabServiceName, int totalCabs)  Initialize all the instance variables appropriately with the values passed to the constructor. calculateRewardPrice(Driver driver)  Calculate and return the bonus of the driver based on the below table. If averageRating of the driver is less than 4, return the bonus as 0.                  In case of any invalid value, return the bonus as 0.  Note: Round off the bonus to 2 decimal digits.  Implement the appropriate getter and setter methods.  Perform case-sensitive comparison wherever applicable.  Test the functionalities using the provided Tester class.      Sample Input and Output  Input  For CabServiceProvider object cabServiceProvider1 with cabServiceName = Halo and totalCabs = 50  Driver object - driver1    Driver object - driver2    Driver object - driver3    Output





String - Exercise 1

 String - Exercise 1


Complete the removeWhiteSpaces() method given in the Tester class.

Method Description

removeWhiteSpaces(String str)

  • Remove all the white spaces from the string passed to the method and return the modified string.

Test the functionalities using the main() method of the Tester class. 

 

Sample Input and Output


class Tester{

public static String removeWhiteSpaces(String str){
String noSpaceStr=str.replaceAll("\\s","");//usingbuiltinmethod
//Implementyourcodehereandchangethereturnvalueaccordingly
return noSpaceStr;
    }
   
    public static void main(String args[]){
        String str = "Hello   How are you   ";
        str = removeWhiteSpaces(str);
        System.out.println(str);
    }
}

coding savior,infosys assignment quiz and lex genrric ansewer,infosys generic java program, code answer,code saviour,code monk,coding bar,code solution for infosys  assignmenet,code saviour trend




Free Resume Template

Creating a blog post that discusses the pros and cons of using a resume rule is a great way to provide valuable information to job seekers ...