Untitled

 avatar
unknown
plain_text
2 years ago
2.9 kB
7
Indexable
package Lab5;
import java.util.Scanner;

public class ComputerSystem {
    private String name;
    private String type;
    private String processor;
    private String motherb;
    private String opticald;
    private int ram;
    private int hdd;
    
    public ComputerSystem(){
        //Default COnstructor.
    }
    public void getDetailsFromUser(){
        Scanner input=new Scanner(System.in);
        System.out.print("*********Enter details**********\n");
        System.out.print("Computer Name:");
        name=input.nextLine();
        System.out.print("Computer Type:");
        type=input.nextLine();
        System.out.print("Computer Processor specs:");
        processor=input.nextLine();
        System.out.print("Computer Motherboard:");
        motherb=input.nextLine();
        System.out.print("Computer Optical drive:");
        opticald=input.nextLine();
        System.out.print("Computer RAM:");
        ram=input.nextInt();
        input.nextLine();
        System.out.print("Computer HDD:");
        hdd=input.nextInt();
    }
    public void displayDetails(){
        System.out.println("*******Display****");
        System.out.println("Computer Name:"+name);
        System.out.println("Computer Type:"+type);
        System.out.println("Processor Specs:"+processor);
        System.out.println("Computer Motherboard:"+motherb);
        System.out.println("Computer Optical Drive:"+opticald);
        System.out.println("Computer RAM:"+ram+" GB");
        System.out.println("Computer HDD:"+hdd+" GB");
        
    }
    public void changeDetails(){
        Scanner input=new Scanner(System.in);
        int ch;
        System.out.println("Which detail do you want to change");
        System.out.println("PRESS: 1 for name;2 for Type; 3 for processor; 4 for motherboard");
        System.out.println("5 for Optical drive; 6 for RAM;7 for HDD");
        ch=input.nextInt();
        if(ch==1)
        {
            name=input.next();
        }
        else if (ch==2)
        {
            type=input.next();
        }
        else if (ch==3)
        {
            processor=input.next();
        }
        else if (ch==4)
        {
            motherb=input.next();
        }
        else if (ch==5)
        {
            opticald=input.next();
        }
        else if (ch==6)
        {
            ram=input.nextInt();
        }
        else if (ch==7)
        {
            hdd=input.nextInt();
        }
        else{
            System.out.println("Invalid Choice");
        }
    }
    public static void Main(String[] args){
        ComputerSystem obj=new ComputerSystem();
        obj.getDetailsFromUser();
        obj.displayDetails();
        obj.changeDetails();
        obj.displayDetails();
    }

}   

Editor is loading...