Answered You can hire a professional tutor to get the answer.

QUESTION

I'm getting error when i compile this program on a command prompt.

I'm getting error when i compile this program on a command prompt.

Please i need help to rectifying the error message that i am getting when compiling Teat Headphones program:

//Import required Java Class

import java.util.Scanner;

public class TestHeadPhones {

public static void main(String[] args) {

// Program Intro

System.out.println("n");

System.out.println("***********************************");

System.out.println("* HeadPhone Variables and Results *");

System.out.println("************************************");

//Construct HeadPhone and Change Volume

HeadPhone HP1 = new HeadPhone();

HP1.ChangeVolume(3);

HeadPhone HP2 = new HeadPhone(1, true, "Sony", "Silver", "MDR-1A", 265.55);

HP2.ChangeVolume(2);

HeadPhone HP3 = new HeadPhone(3, false, "Audeze", "Charcoal", "Sine", 799.50);

HP3.ChangeVolume(1);

//***User Entry***

//Declare Variables

String mfg, model, color;

double cost = 0;

int vol = 0;

char plg, choice;

char choice1 = 'y';

boolean pass;

//Create Scanner Utility

Scanner input = new Scanner(System.in);

System.out.println();

System.out.print("Do you wnat to enter a new HeadPhone? y/n: ");

choice1 = input.nextLine().charAt(0);

if(choice1 !='y' && choice1 !='n') {

do {

   System.out.println("Choice must be y or n.");

   System.out.print("please try again: ');

   Choice1 = input.nextLine().charAt(0);

}

while (Choice1 !='y' && choice1 !='n');

}

if(choice1 == 'y') {

   do {

    //Prompt User for HeadPhone Manufacturer

    System.out.println();

    System.out.print("Enter HeadPhone Manufacturer Name: ");

     mfg = input.nextLine();

//Prompt User for HeadPhone Model

System.out.println();

System.out.print("Enter HeadPhone Model:");

double cost = 0;

int vol = 0;

char plg, choice;

char choice = 'y';

boolena pass;

//Create Scanner Utility

Scanner input = new Scanner(System.in);

System.out.println();

System.out.print("Do you want to enter a new Headphone? y/n: ");

choice1 = input.nextLine().charAt(0);

if(choice1 != 'y' && choice1 !='n') {

do {

System.out.println("Choice must be y or n.");

System.out.print("please try again: ");

choice1 = input.nextLine().charAt(0);

}

while(choice1 != 'y' && choice1 != 'n');

}

if(choice1 == 'y') {

do {

//Prompt User for HeadPhone Manufacturer

System.out.println();

System.out.print("Enter Headphone Manufacturer Name: ");

mfg = input.nextLine();

//Prompt User for HeadPhone Model

System.out.println();

System.outy.print("Enter HeadPhone Model");

model = input.nextLine();

//Prompt User for Headphone Color

System.out.println();

System.out.print("Enter HeadPhone Color: ");

color = input.nextLine();

//Prompt User for HeadPhone Cost

System.out.println();

System.out.print("Enter HeadPhone Cost: ");

cost = input.nextDouble();

if(cost<0) {

do {

System.out.println("Cost must be 0 or greater.");

System.out.print("Please try again: ");

cost = input.nextDouble();

}

while (cost<0);

}

//Prompt User for HeadPhone Volume

System.out.println();

System.out.print("Enter HeadPhone Volume...1 for Low, 2 for Medium,3 for High: ");

vol = input.nextInt();

if(vol<1 || vol>3) {

do {

System.outprintln("Volume must be 1,2 or 3.");

System.out.print("Please try agian:");

vol = input.nextInt();

}

while(vol<1 || vol>3);

}

//Prompt User for HeadPhone Plugged In

System.out.println();

System.out.print("Enter HeadPhone Plugged In? y/n:");

plg = input.next().charAT(0);

if(plg == 'y') {

pass = true:

} else pass = false;

//Create User Input Object

HeadPhone HP4 = new HeadPhone(vol,pass,mfg,color,model,cost);

//Prompt User to continue

input.nextLine();

System.out.print("Do you wish enter more HeadPhones?y/n:");

choice = input.nextLine().charAt(0);

if(choice !='y' && choice !='n') {

do {

System.out.println("Choice must be y or n.");

System.out.print("Please try again:");

choice = input.nextLine().charAt(0);

}

while(choice !='y' && choice !='n');

}

}

while(choice == choice);

System.out.println();

System.out.println("You have chosen not to continue.Good bye.");

} else {

System.out.println();

System.out.println("You have chosen not to continue. Good bye.")'

}

}

}

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question