Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create java code for problem 6 a chapter 4 for Java programs To accompany Progra

ID: 3863699 • Letter: C

Question

Create java code for problem 6 a chapter 4 for Java programs To accompany Programming Logic and Design Jo Ann Smith

Im having trouble compiling. My code does not recognize any strings or int.

/* Barking Lot Bill calculation and display */

import javax.swing.JOptionPane; //Importing for pretty user input windows

public class BarkingLot //Begin BarkingLot class
{
public static void main(String args[]) //Begin main method
{

// variable Declarations
  
String owneridnumberString;
String nameString;
String breedString;
String ageString;
String weightString;
  
int myidnumber;
int age;
int weight;
int totalBill;   
  
//System welcome
System.out.println("Welcome to the Barking Lot. ");

  
//Getting Input from users
  
  
  
owneridnumberString = JOptionPane.ShowInputDialog ("Enter owners ID number");
nameString = JOptionPane.ShowInputDialog ("Enter dogs name");
breedString = JOptionPane.ShowInputDialog ("Enter dogs breed");
ageString = JOptionPane.ShowInputDialog ("Enter dogs age");
weightString = JOptionPane.ShowInputDialog ("Enter dogs weight");


owneridnumber = Integer.parseInt(owneridnumberString);
age = Integer.parseInt(ageString);
weight = Integer.parseInt(weightString);


  
// Calculate bill
  
  


if( weight < 15 )
   totalBill= 55;
else if ((weight > 15) && (weight <= 30))
    totalBill = 75;
else if (( weight > 30) && (weight <=80) )
totalBill = 105;
else if ( weight >80)
totalBill = 125;
  
// output (print) bill
System.out.println (owneridnumber+" "+name+" "+breed+" "+age+" "+weight+" "+totalBill);
  
  
System.exit(0); //Ending program
  
} //End main method


} //End BarkingLot class

I get the following errors:

BarkingLot.java:31: error: cannot find symbol
owneridnumberString = JOptionPane.ShowInputDialog ("Enter owners ID number");
^
symbol: method ShowInputDialog(String)
location: class JOptionPane
BarkingLot.java:32: error: cannot find symbol
nameString = JOptionPane.ShowInputDialog ("Enter dogs name");
^
symbol: method ShowInputDialog(String)
location: class JOptionPane
BarkingLot.java:33: error: cannot find symbol
breedString = JOptionPane.ShowInputDialog ("Enter dogs breed");
^
symbol: method ShowInputDialog(String)
location: class JOptionPane
BarkingLot.java:34: error: cannot find symbol
ageString = JOptionPane.ShowInputDialog ("Enter dogs age");
^
symbol: method ShowInputDialog(String)
location: class JOptionPane
BarkingLot.java:35: error: cannot find symbol
weightString = JOptionPane.ShowInputDialog ("Enter dogs weight");
^
symbol: method ShowInputDialog(String)
location: class JOptionPane
BarkingLot.java:38: error: cannot find symbol
owneridnumber = Integer.parseInt(owneridnumberString);
^
symbol: variable owneridnumber
location: class BarkingLot
BarkingLot.java:59: error: cannot find symbol
System.out.println (owneridnumber+" "+name+" "+breed+" "+age+" "+weight+" "+totalBill);
^
symbol: variable owneridnumber
location: class BarkingLot
BarkingLot.java:59: error: cannot find symbol
System.out.println (owneridnumber+" "+name+" "+breed+" "+age+" "+weight+" "+totalBill);
^
symbol: variable name
location: class BarkingLot
BarkingLot.java:59: error: cannot find symbol
System.out.println (owneridnumber+" "+name+" "+breed+" "+age+" "+weight+" "+totalBill);
^
symbol: variable breed
location: class BarkingLot
9 errors

----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.

Explanation / Answer

So, I saw the complete code and all the errors when I wrote this code in my IDE.

You are getting some errors due to typing mistake. Other errors are because you have defined variable of one name and used some other name. Let me give all the errors' resolution..

These are the solutions for every errors mentioned and I checked and executed the modified code, it is working fine.

The modified program is:

Code:

/* Barking Lot Bill calculation and display */
import javax.swing.JOptionPane; //Importing for pretty user input windows
public class BarkingLot //Begin BarkingLot class
{
public static void main(String args[]) //Begin main method
{

// variable Declarations
  
String owneridnumberString;
String nameString;
String breedString;
String ageString;
String weightString;
  
int myidnumber;
int age;
int weight;
int totalBill = 0;   
  
//System welcome
System.out.println("Welcome to the Barking Lot. ");
  
//Getting Input from users
  
  
  
owneridnumberString = JOptionPane.showInputDialog ("Enter owners ID number");
nameString = JOptionPane.showInputDialog ("Enter dogs name");
breedString = JOptionPane.showInputDialog ("Enter dogs breed");
ageString = JOptionPane.showInputDialog ("Enter dogs age");
weightString = JOptionPane.showInputDialog ("Enter dogs weight");

myidnumber = Integer.parseInt(owneridnumberString);
age = Integer.parseInt(ageString);
weight = Integer.parseInt(weightString);

  
// Calculate bill
  
  

if( weight < 15 )
totalBill= 55;
else if ((weight > 15) && (weight <= 30))
totalBill = 75;
else if (( weight > 30) && (weight <=80) )
totalBill = 105;
else if ( weight >80)
totalBill = 125;
  
// output (print) bill
System.out.println (myidnumber+" "+nameString+" "+breedString+" "+age+" "+weight+" "+totalBill);
  
  
System.exit(0); //Ending program
  
} //End main method

} //End BarkingLot class


Please comment if there is any query. Thank you. :)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote