Offer to customers in Java program

Question :

A leading network company has planned o provide various offers and remainders to their customer based on the plan they have chosen. Currently, they have the details of their customers in the following template customerid, planid, customerPhoneNumber, customerName. Help them with your java skills to segregate the Customers along with their phone numbers based on their given plan.

Adhere to the sample input and output.

Note: If the number of customers is less than 3, display “Customer court is too low” and terminate the program if the number of customers is less than 0 display “Invalid input” and terminate the program if the number of customers is greater than 50 display “Customer count is too high” and terminate the program.

Assumption: All the details of the customer will be valid.

Code :

import java.util.*;
public class Main {
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		System.out.println("Enter the customer details");
		int n=sc.nextInt();
		if(n<0){
			System.out.println("Invalid Input");
		}
		else if(n<3){
			System.out.println("Customer count is too low");
		}
		else if(n>50){
			System.out.println("Customer count is too high");
		}
		else{
			String a[]=new String[n];
			String b[][] = new String[n][4];
			System.out.println("Enter the customer details");
			for(int i=0;i<n;i++){
				a[i] = sc.next();
				b[i] = a[i].split(":");
			}
			System.out.println("Enter the plan to be searched");
			int m=sc.nextInt();
			
			for(int i=0;i<n;i++){
				if(Integer.parseInt(b[i][1])==m){
					System.out.println(b[i][3]+" "+Long.parseLong(b[i][2]));
				}
			}
		}
	}
}

Recommended:

  1. Numerology Name Checking
  2. OMR Evaluation
  3. Java program to Sum of Even Elements
  4. Alternate Number differences in Java
  5. Bike Rent Program in Java
  6. Character Addition in Java
  7. Sum of integers at even or odd places in Java

Leave a Comment

Your email address will not be published. Required fields are marked *

x