0% found this document useful (0 votes)
16 views4 pages

Amobile

Uploaded by

Aarya Thorat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views4 pages

Amobile

Uploaded by

Aarya Thorat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

import java.util.

*;

/**
* Mobile Store Management System
* This program simulates a simple mobile store management system.
* Users can view mobile details, add new mobile details, and generate customer bills.
*/
public class Mobile {

// Arrays for storing mobile details


static String brand[] = {"Iphone", "Iphone", "Moto G", "Moto G", "Samsung", "Samsung", " ", " ", "
", " "};
static String model[] = {"6s", "8+", "G4+", "Tb", "J7", "J8", " ", " ", " ", " "};
static int price[] = {36992, 49490, 84490, 12393, 15000, 12678, 0, 0, 0, 0};

// Arrays for storing unique brands and customer details


static String brands[] = {"Iphone", "Moto G", "Samsung", " ", " ", " "};
static int scustcode[] = {1300, 1301, 1302, 0, 0};
static String scustnm[] = {"HMM Ltd", "Pankaj Shah", "Ajay Aggarwal", " ", " "};
static String custadd[] = {"Barakhamba Road,Delhi", "Golden Oak, Mumbai", "Green Park, Pune", "
", " "};

static int inv = 13000; // Initial invoice number


static int g = 0; // Count of generated invoices

/**
* Main method - Entry point of the program.
* Provides a menu-driven interface for managing mobile store operations.
*/
public static void main() {
Scanner sc = new Scanner(System.in);
int flag = 0; // Control variable for exiting the program

while (flag == 0) {
System.out.println('\f'); // Clear screen
System.out.println("Developed by Software Development Group....");
heading('-'); // Display heading
System.out.println("WELCOME TO THE BEST MOBILE STORE");
heading('-');

// Display menu options


System.out.println("1. Details of Mobiles");
System.out.println("2. Adding New Mobile Details");
System.out.println("3. Generating Customer Bill");
System.out.println("4. Exit");
heading('-');

int n2 = 0;

// Validate user input for numeric choice


while (!sc.hasNextInt()) {
System.out.print("Please enter numeric choice: ");
sc.next();
}
n2 = sc.nextInt();

switch (n2) {
case 1:
// Display mobile details
displayMobileDetails();
break;

case 2:
// Add new mobile details
add();
break;

case 3:
// Generate customer bill
bill();
break;

case 4:
// Exit the program
flag = 1;
break;

default:
System.out.println("Invalid Input");
}

if (flag == 1) break;
}
}

/**
* Displays a heading line with a specified character.
*
* @param hd Character to use for the heading line.
*/
public static void heading(char hd) {
for (int hd1 = 0; hd1 <= 80; hd1++) {
System.out.print(hd);
}
System.out.println();
}

/**
* Prompts the user to press a key to continue.
*/
public static void pressKey() {
Scanner sc = new Scanner(System.in);
int ar = 0;
while (true) {
System.out.println("Press 1 to continue....");
ar = sc.nextInt();
if (ar == 1) break;
}
}

/**
* Adds a new mobile to the store's inventory.
*/
public static void add() {
Scanner sc = new Scanner(System.in);
System.out.println('\f');
heading('-');
System.out.println("WELCOME TO THE BEST MOBILE STORE");
heading('-');

String brd = "", mod = "", temp = "";


int pr = 0;

System.out.println("Please Enter Details of New Mobile");


System.out.print("Brand: ");
brd = sc.nextLine();
System.out.print("Model: ");
mod = sc.nextLine();
System.out.print("Price: ");

while (!sc.hasNextInt()) {
System.out.print("Please enter numeric price: ");
sc.next();
}
pr = sc.nextInt();

// Add new mobile details to arrays


for (int i = 0; i < brand.length; i++) {
if (brand[i].equals(" ")) {
brand[i] = brd;
model[i] = mod;
price[i] = pr;
break;
}
}

// Add new brand to the unique brands array if necessary


for (int i = 0; i < brands.length; i++) {
if (brands[i].equals(brd)) break;
if (brands[i].equals(" ")) {
brands[i] = brd;
break;
}
}

heading('-');
pressKey();
}

/**
* Generates a customer bill.
*/
public static void bill() {
// Implementation for billing...
}

/**
* Displays details of all available mobiles.
*/
public static void displayMobileDetails() {
System.out.println('\f');
heading('-');
System.out.println("WELCOME TO THE BEST MOBILE STORE");
heading('-');
System.out.println("Brand \t\t\t Model \t\t\t\t Price");
heading('=');

for (int i = 0; i < brand.length; i++) {


if (!brand[i].equals(" ")) {
System.out.println(brand[i] + "\t\t\t" + model[i] + "\t\t\t\t" + price[i]);
}
}

heading('=');
pressKey();
}
}

You might also like