Question

In: Computer Science

JAVA CODE --- from the book, java programming (7th edition) chapter 7 carly's question I am...

JAVA CODE ---

from the book, java programming (7th edition) chapter 7 carly's question

I am getting a illegal expression error and don't know how to fix it, also may be a few other error please help

CODE BELOW

import java.util.Scanner;
public class Event
{
public static double pricePerGuestHigh = 35.00;
public static double pricePerGuestLow = 32.00;
public static final int LARGE_EVENT_MAX = 50;
public String phnum="";
public String eventNumber="";
private int guests;
private double pricePerEvent;

public void setPhoneNumber()
{
Scanner s = new Scanner(System.in);
int count = 0;

System.out.println("Enter Phone Number: ");
String pnumb=s.nextLine();
int len=pnumb.length();
for(int i=0;i
{
char c=pnumb.charAt(i);
if(Character.isDigit(c))
{
count++;
String ss=Character.toString(c);
phnum=phnum.concat(ss);
}
}

if(count!=10)
{
phnum="";
phnum=phnum.concat("0000000000");
}

}
public String getPhoneNumber()
{
String ret="("+this.phnum.charAt(0)
+""+this.phnum.charAt(1)+""+this.phnum.charAt(2)
+")"+this.phnum.charAt(3)+""+this.phnum.charAt(4)
+""+this.phnum.charAt(5)+""+this.phnum.charAt(6)
+""+this.phnum.charAt(7)+""+this.phnum.charAt(8)
+""+this.phnum.charAt(9);

return ret;
}

public void setEventNumber()
{
Scanner scanner = new Scanner(System.in);
int len;
System.out.println("Enter 4 digit event number: ");
String enumb = scanner.nextLine();

len=enumb = scanner.nextLine();
len=enumb.length();

char c1,c2,c3,c4;
String defv="A000";
c1=enumb.charAt(0);
c2=enumb.charAt(1);
c3=enumb.charAt(2);
c4=enumb.charAt(3);

if(Character.isLetter(c1) &&
Character.isDigit(c2) &&
Character.isDigit(c3) &&
Character.isDigit(c4))
{
enumb=enumb.toUpperCase();
eventNumber=eventNumber.concat(enumb);
}

else
{
eventNumber=eventNumber.concat(defv);
}

}

public void setGuests(int guests)
{

this.guests = guests;
if(isLargeEvent())
PricePerEvent=pricePerGuestHigh;
else
PricePerEvent=pricePerGuestLow;
}
public int getGuestCount()
{
return guests;
}
public boolean isLargeEvent()
{
if(guest>= LARGE_EVENT_MAX)
{
return true;
}
else if (guests < LARGE_EVENT_MAX)
{
return false;
}

return isLargeEvent();
}

public String getEventNumber()
{
String ret1="Event Number:"
+this.eventNumber;
return ret1;
}
public int getGuests(boolean largeEvent)
{
return guests;
}

}

Solutions

Expert Solution

import java.util.Scanner;

public class Event
{
   public static double pricePerGuestHigh = 35.00;
   public static double pricePerGuestLow = 32.00;
   public static final int LARGE_EVENT_MAX = 50;
   public String phnum="";
   public String eventNumber="";
   private int guests;
   private double pricePerEvent;
  
   public void setPhoneNumber()
   {
       Scanner s = new Scanner(System.in);
       int count = 0;
      
       System.out.println("Enter Phone Number: ");
       String pnumb=s.nextLine();
       int len=pnumb.length();

       for(int i=0;i<len; i++)
       {
           char c=pnumb.charAt(i);
           if(Character.isDigit(c))
           {
               count++;
               String ss=Character.toString(c);
               phnum=phnum.concat(ss);
           }
       }
      
       if(count!=10)
       {
           phnum="";
           phnum=phnum.concat("0000000000");
       }  
   }

   public String getPhoneNumber()
   {
       String ret="("+this.phnum.charAt(0)
       +""+this.phnum.charAt(1)+""+this.phnum.charAt(2)
       +")"+this.phnum.charAt(3)+""+this.phnum.charAt(4)
       +""+this.phnum.charAt(5)+""+this.phnum.charAt(6)
       +""+this.phnum.charAt(7)+""+this.phnum.charAt(8)
       +""+this.phnum.charAt(9);
  
       return ret;
   }
  
   public void setEventNumber()
   {
       Scanner scanner = new Scanner(System.in);
       int len;
       System.out.println("Enter 4 digit event number: ");
       String enumb = scanner.nextLine();
      
       len=enumb.length();
      
       char c1,c2,c3,c4;
       String defv="A000";
       c1=enumb.charAt(0);
       c2=enumb.charAt(1);
       c3=enumb.charAt(2);
       c4=enumb.charAt(3);
      
       if(Character.isLetter(c1) &&
       Character.isDigit(c2) &&
       Character.isDigit(c3) &&
       Character.isDigit(c4))
       {
           enumb=enumb.toUpperCase();
           eventNumber=eventNumber.concat(enumb);
       }      
       else
       {
           eventNumber=eventNumber.concat(defv);
       }
   }
  
   public void setGuests(int guests)
   {
       this.guests = guests;
       if(isLargeEvent())
           pricePerEvent=pricePerGuestHigh;
       else
           pricePerEvent=pricePerGuestLow;
   }

   public int getGuestCount()
   {
       return guests;
   }
  
   public boolean isLargeEvent()
   {
       if(guests>= LARGE_EVENT_MAX)
       {
           return true;
       }
       else if (guests < LARGE_EVENT_MAX)
       {
           return false;
       }
  
       return isLargeEvent();
   }
  
   public String getEventNumber()
   {
       String ret1="Event Number:"
       +this.eventNumber;
       return ret1;
   }

   public int getGuests(boolean largeEvent)
   {
       return guests;
   }
}

/************************************************************************/

/* You can add the following main method */

class Driver
{
   public static void main (String[] args)
   {
       Event e = new Event();
       e.setPhoneNumber();
       e.setEventNumber();
       e.setGuests(2);
   }
}


Related Solutions

Question 41 on chapter 7. Book Cost Management 7th edition. Support Departments Operating Departments Information Technology...
Question 41 on chapter 7. Book Cost Management 7th edition. Support Departments Operating Departments Information Technology Operations Claims Processing Admisnistration Sales Information Technology 20 20 40 20 Operations 10 10 50 30 IT 600,000 Operations 1,800,000 Claims Process. 450,000 Administration 850,000 Sales 650,000 Total Cost 4,350,000 Required Use 4 or more decimal places in your calculations. Allocate the $4350,000 total departmental costs to all three operating departments using (a) the direct method, (b) the step method, and 9c) the reciprocal...
In regards to Statistics: the exploration and and analysis of data (7th edition), chapter 13, question...
In regards to Statistics: the exploration and and analysis of data (7th edition), chapter 13, question 43. Part a of the question asks for the equation of an estimated regression line. The solution is already on chegg, but my question is: why are SSR, Se, and Sb still calculated, after y-hat=2.7...+(0.04...)x has already been solved for?
Elementary Statistics (7th edition) Chapter 8 review question 7 For Exercises 1 through 20, perform each...
Elementary Statistics (7th edition) Chapter 8 review question 7 For Exercises 1 through 20, perform each of the following steps. State the hypotheses and identify the claim. Find the critical value(s). Compute the test value. Make the decision. Summarize the results 7. Weights of Men’s Soccer Shoes Is lighter better? A random sample of men’s soccer shoes from an inter-national catalog had the following weights (in ounces). 10.8 9.8 8.8 9.6 9.9 10 8.4 9.6 10 9.4 9.8 9.4 9.8...
Chapter 7 Case         Brewer, Garrison, Noreen         Introduction to Managerial Accounting, 7th Edition         - Refer to the...
Chapter 7 Case         Brewer, Garrison, Noreen         Introduction to Managerial Accounting, 7th Edition         - Refer to the end-of-chapter case for Chapter 7 (book pages 344-346)         - Use templates provided in this workbook to complete requirements #1 - #4. Follow instructions on templates.         - Save Excel file and print out entire workbook incl. Instructions tab (worksheets are formatted for printing).          - Submit budget hard copy and upload Excel file to Titanium.          - Team members must sign Instructions page to receive...
I am reviewing the International Economics textbook (10th edition), Chapter 14, Question 6. The question asks:...
I am reviewing the International Economics textbook (10th edition), Chapter 14, Question 6. The question asks: Part A: A 10,000 GBP deposit in a London bank in a year has an interest rate in pounds of 10%. The USD/GBP exchange rate moves from $1.50 per pound to $1.38 per pound. What is the dollar rate of return on this asset? This part I understood and I calculated as: Year 0 = 10,000 GBP * 1.50 exchange rate = 15,000 USD...
The readings and images come from the book Fiero, Gloria K., The Humanistic Tradition, 7th edition,...
The readings and images come from the book Fiero, Gloria K., The Humanistic Tradition, 7th edition, vol. II. 1) In Discourse on Method (Reading 23.3) how does Rene Descartes prove (at least to his own satisfaction) that the mind and body are separate and distinct from each other? 2) How do Thomas Hobbes and John Locke differ in their views of human nature? Why did each of them believe men create governments? Did you think Adam Smith would agree more...
java from control structures through objects 6th edition, programming challenge 5 on chapter 16 Write a...
java from control structures through objects 6th edition, programming challenge 5 on chapter 16 Write a boolean method that uses recursion to determine whether a string argument is a palindrome. the method should return true if the argument reads the same forward amd backword. Demonstrate the method in a program, use comments in the code for better understanding. there must be a demo class and method class also .. generate javadocs through eclipse compiler. And make a UML diagram with...
Book - Introduction to Programming Using Visual Basic 11th Edition by David I. Schneider Programming Language...
Book - Introduction to Programming Using Visual Basic 11th Edition by David I. Schneider Programming Language - Visual Studio 2017 RESTAURANT MENU Write a program to place an order from the restaurant menu in Table 4.13. Use the form in Fig. 4.70, and write the program so that each group box is invisible and becomes visible only when its corresponding check box is checked. After the button is clicked, the cost of the meal should be calculated. (NOTE: The Checked...
From the book Quality Management for Organizational Excellence: Introduction to Total Quality (7th Edition) PLEASE ANSWER...
From the book Quality Management for Organizational Excellence: Introduction to Total Quality (7th Edition) PLEASE ANSWER THE QUESTIONS FULLY (page 64) !!!! THANK YOU!!! Q1/ List and describe the steps involved in laying the foundation for a quality culture. Q2/ Explain why the implementation of total quality requires cultural change?
Book: Managerial Accounting - The Cornerstone of Business Decision Making, 7th Edition For this assignment discuss...
Book: Managerial Accounting - The Cornerstone of Business Decision Making, 7th Edition For this assignment discuss the importance of ethics in managerial accounting. What issues may arise if ethics is compromised? How would this impact the company internally, how would it impact the external users such as investors, creditors, government, etc? Please make sure to utilize your points of view, as they matter the most to me. I am not interested in an article from the internet.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT