Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

else if ( command. equals ( getLimit )) { //get a maximum limit of data for a call to the argument zone boolean invalidArgs =

else if (command.equals("getLimit")) { //get a maximum limit of data for a call to the argument zone boolean invalidArgs = false; long no = 0; int passwd = 0; String callZone = null; if(inl.hasNextLong()) { no = inl.nextLong(); } else{ invalidArgs = true; } if(!invalidArgs && inl.hasNextInt()) { passwd = inl.nextInt(); } else{ invalidArgs = true; } if(!invalidArgs && (no <= 0 || passwd <= 0)) { invalidArgs = true; } if(!invalidArgs && inl.hasNext()) { callZone = inl.next(); } if(!CallZone.isValidZone(zone)) { invalidArgs = true; } if(invalidArgs) { //error messages if command not executed successfully System.out.println("Error : invalid arguments for getLimit command"); } else{ PhoneCard card = ct.get(no); if(card == null) { System.out.println("Error : card no " + no + "does not exist"); } else if(card.getPassword() != passwd) { System.out.println("Error : password" + passwd + "incorrect"); } else if(!card.allowed(callZone)) { System.out.println("Error : card " + no + "not allowed for zone " + callZone); } else { System.out.println("Result : card " + no + "limit for zone " + callZone + "is " + card.getLimit(callZone) + "minutes"); } }       } else if (command.equals("charge")) { // get the charge command executed boolean invalidArgs = false; long no = 0; int passwd = 0; String callZone = null; int min = 0; if(inl.hasNextLong()) { no = inl.nextLong(); } else{ invalidArgs = true; } if(!invalidArgs && inl.hasNextInt()) { passwd = inl.nextInt(); } else{ invalidArgs = true; } if(!invalidArgs && (no <= 0 || passwd <= 0)) { invalidArgs = true; } if(!invalidArgs && inl.hasNext()){ callZone = inl.next(); } if(!CallZone.isValidZone(zone)){ invalidArgs = true; } if(!invalidArgs && inl.hasNextInt()) { min = inl.nextInt(); } if(!invalidArgs && min <= 0) { invalidArgs = true; } if(invalidArgs) { //error messages if command not executed successfully System.out.println("Error : invalid arguments for charge command"); } else { PhoneCard card = ct.get(no); if(card == null) { System.out.println("Error : card no " + no + "does not exist"); } else if(card.getPassword() != passwd) { System.out.println("Error : password " + passwd + "incorrect"); } else if(!card.allowed(callZone)) { System.out.println("Error : card " + no + "not allowed for zone " + callZone); } else if(!card.charge(min , callZone) && card.getBalance() < card.costPerMin(callZone)*((double)min)) { System.out.println("Error : card " + no + "limit for zone " + callZone + "is " + card.getLimit(callZone) + "minutes"); } else { System.out.println("Result : card " + no + "charged " + (card.costPerMin(callZone)*((double)min)) + ", new balance is " + card.getBalance()); } } 

> javac SuperPhoneCardInc.java

SuperPhoneCardInc.java:123: error: cannot find symbol

if(!CallZone.isValidZone(zone)) {

^

symbol:variable zone

location: class SuperPhoneCardInc

SuperPhoneCardInc.java:134: error: incompatible types: String cannot be converted to CallZone

} else if(!card.allowed(callZone)) {

^

SuperPhoneCardInc.java:138: error: incompatible types: String cannot be converted to CallZone

card.getLimit(callZone) + "minutes");

^

SuperPhoneCardInc.java:164: error: cannot find symbol

if(!CallZone.isValidZone(zone)){

^

symbol:variable zone

location: class SuperPhoneCardInc

SuperPhoneCardInc.java:182: error: incompatible types: String cannot be converted to CallZone

} else if(!card.allowed(callZone)) {

^

SuperPhoneCardInc.java:184: error: incompatible types: String cannot be converted to CallZone

} else if(!card.charge(min , callZone) && card.getBalance() < card.costPerMin(callZone)*((double)min)) {

^

SuperPhoneCardInc.java:184: error: incompatible types: String cannot be converted to CallZone

} else if(!card.charge(min , callZone) && card.getBalance() < card.costPerMin(callZone)*((double)min)) {

^

SuperPhoneCardInc.java:186: error: incompatible types: String cannot be converted to CallZone

card.getLimit(callZone) + "minutes");

^

SuperPhoneCardInc.java:189: error: incompatible types: String cannot be converted to CallZone

(card.costPerMin(callZone)*((double)min)) + ", new balance is " + card.getBalance());

^

Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output

I don't know how to resolve this.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions