Answer to Question #324199 in Java | JSP | JSF for michel

Question #324199

Jaya Jusco (JJ) Sdn Bhd needs you to develop an application to calculate their customer JJ point’s reward. Define a class named Customer with the following variables declarations:


String CustName;

String CustAddress;

int pointRewards;

 

  1.  Provide a default constructor and another constructor with three parameters. The constructor with parameters will assign the three values (String CustomerName, String CustomerAddress, int point). Define a public instance method named calculatePoint()to calculate the customer rewards if the point is greater than 300 points. The formula indicates that if the point is greater than 300 points, the system will add up extra 50 points.
  2. Define another class named Testing to test the Customer class. Use the Scanner method to get the CustomerName, CustomerAddress and point values from the user. Declare class and create object Customer. Call the calculatePoint( ) method to display the current customer points reward.  
1
Expert's answer
2022-04-05T15:30:06-0400
package tasks.task1;

import java.util.Scanner;

class Customer{
    String custName;
    String custAddress;
    int pointRewards;

    public Customer(String custName, String custAddress, int pointRewards) {
        this.custName = custName;
        this.custAddress = custAddress;
        this.pointRewards = pointRewards;
        calculatePoint();
    }

    public void calculatePoint( ){
        if(pointRewards > 300)
            pointRewards += 50;
        System.out.println("current client reward in points = " + pointRewards);
    }
}

public class Testing {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        String name = in.nextLine();
        String address = in.nextLine();
        int point = in.nextInt();
        
        Customer cust = new Customer(name, address, point);
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS