Question

This is Java programing.Modify this Java code,so that each franchise can assign and print their own...

This is Java programing.Modify this Java code,so that each franchise can assign and print their own burger price.The programing have at least three franchises. (Use abstract)

class newBurger {

public newBurger() {

}

public void salmonBurger(){

   System.out.println("salmonBurger $5.99");

   System.out.println("Kcal: 294");

}

public void clamBurger(){

   System.out.println("clamBurger $4.99");

   System.out.println("Kcal: 200");

}

public void oysterBurger(){

   System.out.println("oysterBurger $3.50");

   System.out.println("Kcal: 125");

}

}

class franchise1 extends newBurger {

String name = "franchise #1";

public franchise1() {

}

}

public class burger {

   public static void main(String[] args) {

   franchise1 menu = new franchise1();

   System.out.println(menu.name);

   menu.salmonBurger();

   menu.clamBurger();

   menu.oysterBurger();

   }

}

Homework Answers

Answer #1

Hi,I modified the java program in such a way that you can use abstract class and also made each franchise as separate class so that each franchise can also include it's individual properties in itself also with the common properties and mandatory properties.

Hope,you will find this code helpful.Any further information regarding this question or concept or any other question .Please feel free to ask us .We will love to help you

abstract class francshise{

void show();

}

class salmonBurger extends francshise{

public void show(){

System.out.println("salmonBurger $5.99");

System.out.println("Kcal: 294");

}

}

class clamBurger extends francshise{

public void show(){

System.out.println("clamBurger $4.99");

System.out.println("Kcal: 200");

}

}

class  oysterBurger extends francshise{

public void show(){

System.out.println("oysterBurger $3.50");

System.out.println("Kcal: 125");

}

}

public class burger {

public static void main(String[] args) {

System.out.println("Franchise 1 menu);

salmonBurger sb=new  salmonBurger();

sb.show();

clamBurger cb=new clamBurger();

cb.show();

oysterBurger ob=new oysterBurger();

ob.show();

}

}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
The following code should print X is greater than 0. However, the code has errors. Fix...
The following code should print X is greater than 0. However, the code has errors. Fix the code so that it compiles and runs correctly. (Rewrite the program with all the fixes) public class Test1 { public static void main(String[] args) { int x = 3; if (x > 0 System.out.println("x is greater than 0") else System.out.println(x is less than or equal 0"); } } Must be in java and easy to understand grade 11 course
Complete the Java code. The code should print “x is in numbers” if the integer x...
Complete the Java code. The code should print “x is in numbers” if the integer x is one of the values stored in numbers. If x is not in numbers, your code should print “x is not in numbers” public static void main(String[] args){                         int[] numbers = <some array values>;                         int x = <some value>;             }
Read in a file "numbers.txt" into a Java program. Sum up all the even numbers over...
Read in a file "numbers.txt" into a Java program. Sum up all the even numbers over 50. Print the result to the console using System.out.println(); The file will only have numbers. code below import java.io.FileNotFoundException; import java.io.FileReader; import java.util.Scanner; public class ReadingFiles { public static void main(String[] args) throws FileNotFoundException { System.out.println(totalEven); } }
IN JAVA Print "userNum1 is negative." if userNum1 is less than 0. End with newline. Convert...
IN JAVA Print "userNum1 is negative." if userNum1 is less than 0. End with newline. Convert userNum2 to 0 if userNum2 is greater than 10. Otherwise, print "userNum2 is less than or equal to 10.". End with newline. public class UserNums { public static void main (String [] args) { int userNum1; int userNum2; userNum1 = 0; userNum2 = 7; *insert* System.out.println("userNum2 is " + userNum2); } }
What is the output of the following Java program? class Food { Food() { System.out.println(flavor); }...
What is the output of the following Java program? class Food { Food() { System.out.println(flavor); } String flavor = "bland"; } class Pepper extends Food { String flavor = "spicy"; } public class Lunch { public static void main(String[] args) { Food lunch = new Pepper(); } } Select one: a. spicy b. the program does not compile c. bland spicy d. no output e. bland
Complete the Java ocode. The code should print how many times integer x appears in numbers....
Complete the Java ocode. The code should print how many times integer x appears in numbers. For example, if numbers = {2,2,1,3,2,2} and x = 2, your code should print the number 4, because x appears 4 times in the array public static void main(String[] args){                         int[] numbers = <some array values>;                         int x = <some value>;             }
What is the output of the following Java program? class Food { String flavor = "bland";...
What is the output of the following Java program? class Food { String flavor = "bland"; } class Pepper extends Food { String flavor = "spicy"; Pepper(String flavor) { this.flavor = flavor; } } public class Lunch { public static void main(String[] args) { Pepper pepper = new Pepper("sweet"); System.out.println(pepper.flavor); } } Select one: a. bland b. the program does not compile c. no output d. spicy e. sweet
What is the output of the following Java program? public class Food {     static int...
What is the output of the following Java program? public class Food {     static int count;     private String flavor = "sweet";     Food() { count++; }     void setFlavor(String s) { s = flavor; }     String getFlavor() { return flavor; }     static public void main(String[] args) {         Food pepper = new Food();         pepper.setFlavor("spicy");         System.out.println(pepper.getFlavor());     } } Select one: a. sweet b. 1 c. The program does not compile. d. 2 e. spicy...
I am writing code in java to make the design below. :-):-):-):-):-):-)  :-):-):-):-):-):-)  :-):-):-):-):-):-) :-):-):-):-):-):-)  :-):-):-):-):-):-)  :-):-):-):-):-):-) I already have...
I am writing code in java to make the design below. :-):-):-):-):-):-)  :-):-):-):-):-):-)  :-):-):-):-):-):-) :-):-):-):-):-):-)  :-):-):-):-):-):-)  :-):-):-):-):-):-) I already have this much public class Main { int WIDTH = 0; double HEIGHT = 0; public static void drawSmileyFaces() { System.out.println(" :-):-):-):-):-):-)"); } public static void main (String[] args) { for (int WIDTH = 0; WIDTH < 3; WIDTH++ ) { for(double HEIGHT = 0; HEIGHT < 2; HEIGHT++) { drawSmileyFaces(); } } } } I am pretty sure that alot of this is wrong...
1) Consider the following Java program, which one of the following best describes "setFlavor"? public class...
1) Consider the following Java program, which one of the following best describes "setFlavor"? public class Food {     static int count;     private String flavor = "sweet";     Food() { count++; }     void setFlavor(String s) { flavor = s; }     String getFlavor() { return flavor; }     static public void main(String[] args) {         Food pepper = new Food();         System.out.println(pepper.getFlavor());     } } a. a class variable b. a constructor c. a local object variable d....
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT