TestCakeProgram.java:30: error: cannot find symbe ob[i] = new orderCake(w,name,rateO); symbol: variable rateo location: class TestCakeProgram 1 error Jot compiled

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

NEED HELP WITH JAVA PROGRAM

PLEASE HELP THANK YOU .

 

-ERROR SEE IMAGE BELOW

 

Cake.java 

public abstract class Cake{
protected String name;
protected double rate;
protected double calcPrice;
public Cake(String n, double r)
{
name = n;
rate = r;
}
public abstract double calcPrice();
public String toString()
{
return name + "\t" +rate;
}
}
class orderCake extends Cake
{
double weight;
public orderCake(double weight,String n, double r)
{
super(n,r);
this.weight= weight;
}
public double calcPrice()
{
return rate * weight;
}
}
class readymadeCake extends Cake
{
double quantity;
public readymadeCake(double quantity,String n, double r)
{
super(n,r);
this.quantity= quantity;
}
public double calcPrice()
{
return rate * quantity;
}
}

 

TestCakeProgram.java

 

import java.util.Scanner;
class TestCakeProgram
{
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
int choice=0;
System.out.println("ENTER RATE FOR ORDERED CAKE: ");
double rate0=sc.nextDouble();
System.out.println("ENTER RATE FOR READYMADE CAKE: ");
double rateR=sc.nextDouble();

Cake ob[] = new Cake[2];
double w=0,q=0;
double totalO=0.0,totalP=0.0;
double quant=0;
double max=0;
String nameOf="";
String name="";
for(int i=0;i<2;i++)
{
System.out.println("ENTER ( 1 ) ORDER CAKE AND ( 2 ) READYMADE CAKE : ");
choice=sc.nextInt();
if(choice==1)
{
System.out.println("ENTER NAME: ");
name=sc.next();
System.out.println("ENTER WEIGHT: ");
w=sc.nextDouble();
ob[i] = new orderCake(w,name,rateO);
totalO=totalO+ob[i].calcPrice();
if(max<ob[i].calcPrice())
{
max=ob[i].calcPrice;
nameOf=name;
}
}
else if(choice==2)
{
System.out.println("ENTER NAME: ");
name=sc.next();
System.out.println("ENTER QUANTITY: ");
q=sc.nextDouble();
quant =quant +q;
ob[i] = new readymadeCake(q,name,rateR);
totalP=totalP+ob[i].calcPrice();
if(max<ob[i].calcPrice())
{
max=ob[i].calcPrice();
nameOf=name;
}
}
}
System.out.println("TOTAL PRICE OF ALL CAKES: "+totalO+totalP);
System.out.println("TOTAL PRICE OF READYMADE CAKES: "+totalP+"AND QUANTITY IS: "+quant);
System.out.println("HIGHEST PRICE FOR THE CAKE IS: "+max+"CAKE NAME IS:"+nameOf);

}
}

 

TestCakeProgram.java:30: error: cannot find symbol
ob[i] = new orderCake(w,name,rateO);
symbol: variable rateo
location: class TestCakeProgram
1 error
Not compiled
Transcribed Image Text:TestCakeProgram.java:30: error: cannot find symbol ob[i] = new orderCake(w,name,rateO); symbol: variable rateo location: class TestCakeProgram 1 error Not compiled
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY