Homework: Membership Recommendation System

Problem Overview

You are building a membership recommendation system for a fictional company called “Prime Club.” This system will suggest the most suitable membership tier (or tiers) for a user based on their age, annual income, student status, and employment type. There are 4 types of memberships:

Membership Types

  1. Basic Membership:
    • Requirements:
      • Age ≥ 18
      • Annual income ≥ $20,000
  2. Premium Membership:
    • Requirements:
      • Age ≥ 25
      • Annual income ≥ $50,000
  3. Student Discount:
    • Requirements:
      • Must be a student.
  4. Senior Discount:
    • Requirements:
      • Age ≥ 65

Task Description

Using conditional statements, Boolean expressions, and comparison techniques you’ve learned, write a Java program that:

  1. Prompts the user to input the following:
    • Age (as an integer)
    • Annual income (as a double)
    • Student status (yes or no)
    • Employment type (full-time, part-time, unemployed)
  2. Based on these inputs, your program should print out all membership tiers and discounts the user qualifies for. If the user does not qualify for any membership or discount, the program should print:
    “You do not qualify for any memberships or discounts.”

Additional Challenge

Add a final recommendation where your program prioritizes the “best” membership for the user if they qualify for multiple memberships (use an else-if structure).

The best membership should be decided based on the following priorities:

  1. Premium Membership (highest priority)
  2. Senior Discount
  3. Student Discount
  4. Basic Membership (lowest priority)
Hints (click to reveal) 1. **Input Validation:** - Ensure that age is a positive integer, and annual income is a positive double. - Student status input should be case-insensitive ("yes" or "no"). - Employment type should be one of: "full-time", "part-time", or "unemployed." 2. **Conditions to Consider:** - Use `if-else` statements to check for membership qualifications. - Remember to handle multiple conditions where a user qualifies for more than one membership. 3. **Recommendation Logic:** - Use `else-if` statements to prioritize the memberships based on the provided hierarchy.

Constraints

  • Age must be a positive integer.
  • Annual income must be a positive double.
  • Student status should only accept “yes” or “no” (case-insensitive).
  • Employment type should be one of: “full-time”, “part-time”, or “unemployed.”

Senior Discount:

Requirements: Age ≥ 65 Task Description: Using conditional statements, Boolean expressions, and comparison techniques you’ve learned, write a Java program that:

Prompts the user to input the following:

Age (as an integer) Annual income (as a double) Student status (yes or no) Employment type (full-time, part-time, unemployed) Based on these inputs, your program should print out all membership tiers and discounts the user qualifies for. If the user does not qualify for any membership or discount, the program should print out: “You do not qualify for any memberships or discounts.”

Additional Challenge: Add a final recommendation where your program prioritizes the “best” membership for the user if they qualify for multiple memberships (use an else-if structure).

The best membership should be decided based on the following priorities: Premium Membership (highest priority) Senior Discount Student Discount Basic Membership (lowest priority) Constraints: Age must be a positive integer. Annual income must be a positive double. Student status should only accept “yes” or “no” (case-insensitive). Employment type should be one of: “full-time”, “part-time”, or “unemployed.”

import java.util.Scanner;

System.out.println("Welcome to the Prime Club Membership Terminal!");
System.out.println("What is your age?");
Scanner scanner = new Scanner(System.in);
int age = scanner.nextInt();
if(age < 0)
{
    throw new NullPointerException("Only enter a positive value");
}
System.out.println("What is your annual income?");
double income = scanner.nextDouble();
if(income < 0)
{
    throw new NullPointerException("Only enter a positive value");
}
scanner.nextLine();
System.out.println("Are you a student? (yes/no)");
String studentResponse = scanner.nextLine();
studentResponse = studentResponse.toLowerCase();
boolean isStudent = false;
switch(studentResponse)
{
    case "yes":
        isStudent = true;
    break;

    case "no":
        isStudent = false;
    break;

    default:
        throw new NullPointerException("Only enter yes or no");

}

System.out.println("Employment Type (full-time, part-time, unemployed)");
String employment = scanner.nextLine();
if(!(employment.equals("full-time") || employment.equals("part-time") || employment.equals("unemployed")))
{
    throw new NullPointerException("Please only enter the provided values");
}

if(age >= 25 && income >= 50000)
{
    System.out.println("You qualify for a Premium Membership!");
}
else if(age >= 65)
{
    System.out.println("You qualify for a senior discount!");
}
else if(isStudent)
{
    System.out.println("You qualify for a student discount!");
}
else if(age >= 18 && income >= 20000)
{
    System.out.println("You qualify for a Basic Membership!");
}
else
{
    System.out.println("You do not qualify for any memberships.");
}
Welcome to the Prime Club Membership Terminal!
What is your age?
What is your annual income?
Are you a student? (yes/no)
Employment Type (full-time, part-time, unemployed)
You do not qualify for any memberships.