Answer to Question #326073 in Java | JSP | JSF for serrah

Question #326073

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;

 

a)  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.


b)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-08T17:54:34-0400
import java.util.Scanner;

public class Testing {
    public static void main(String[] args) {
    Scanner scan=new Scanner(System.in);
    Scanner scan1=new Scanner(System.in);
    Scanner scan2=new Scanner(System.in);
        System.out.print("Enter your name: ");
        String userName=scan.nextLine();
        System.out.print("Enter your address: ");
        String userAddress=scan1.nextLine();
        System.out.print("Enter your points: ");
        int userPoints=scan2.nextInt();
        Customer customer=new Customer(userName,userAddress,userPoints);
        if(userPoints>300){
            System.out.println("Your points now: "+customer.calculatePoint());
        }
        else{
            System.out.println("Your points: "+userPoints);
        }
    }
}
class Customer{
    String CustName;
    String CustAddress;
    int pointRewards;

    Customer(){
    }

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

    public  int calculatePoint(){
        return pointRewards+50;


    }
}

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