Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help! I need to fix the following errors in my code. The three classes ConicalFrustrum , ConicalFrustrumApp and ConicalFrustrumList were used for this assignment.

Please help! I need to fix the following errors in my code. The three classes "ConicalFrustrum" , "ConicalFrustrumApp" and ConicalFrustrumList were used for this assignment.

05/Completed Code/Project5Test.java:761: error: cannot find symbol int actual = list.numberOfConicalFrustums(); ^ symbol: method numberOfConicalFrustums() location: variable list of type ConicalFrustumList 05/Completed Code/Project5Test.java:776: error: cannot find symbol int actual = list.numberOfConicalFrustums(); ^ symbol: method numberOfConicalFrustums() location: variable list of type ConicalFrustumList 2 errors 

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

6 import java.text.DecimalFormat; 7 /** 8 *Program to print ConicalFrustrum objects. 9 *Uses a scanner class and DecimalFormat class. 10 */ 11 public class ConicalFrustum 12 { 13 //private member variables 14 private String label = ""; 15 private double radius1 = 0.0; 16 private double radius2 = 0.0; 17 private double height = 0.0; 18 /** 19 *Constructor for the class. 20 *@param labelIn command line arguments not used. 21 *@param radius1In command line arguments not used. 22 *@param radius2In command line arguments not used. 23 *@param heightIn command line arguments not used. 24 */ 25 public ConicalFrustum(String labelIn, double radius1In, 26 double radius2In, double heightIn) 27 { 28 this.setLabel(labelIn); 29 this.setRadius1(radius1In); 30 this.setRadius2(radius2In); 31 this.setHeight(heightIn); 32 } 33 /** 34 *if else boolean statement. 35 *@return true. 36 *@param labelIn comman line arguments not used. 37 */ 38 public boolean setLabel(String labelIn) 39 { 40 //check for empty string 41 String s = labelIn.trim(); 42 if (s.equals("")) 43 { 44 return false; 45 } 46 else 47 { 48 this.label = s; 49 return true; 50 } 51 } 52 /** 53 *check for negative radius1. 54 *@return false. 55 *if else statement used. 56 *@param radius1In command line arguments not used. 57 */ 58 public boolean setRadius1(double radius1In) 59 { 60 if (radius1In

*Class for ConicalFrustum 3 *Used to create objects 4 *private field used along with strings 5 *Accessor and mutator methods 6 */ 7 import java.util.Scanner; 8 /** 9 *Scanner class imported 10 *Gets label, radius1, radius2, and height. 11 *App class for ConicalFrustrumApp. 12 * 13 */ 14 public class ConicalFrustrumApp 15 { 16 /** 17 * 18 *Allows user to enter input for program. 19 *@param args command line arguments not used. 20 */ 21 public static void main(String[] args) 22 { 23 //Scanner class to get user input. 24 Scanner input = new Scanner(System.in); 25 String label; 26 //double used to get radius1, radius2, and height. 27 double radius1, radius2, height; 28 System.out.println("Enter label, radius1, radius2, " 29 + "and height for a conical frustrum."); 30 System.out.print("\tlabel: "); 31 label = input.nextLine(); 32 System.out.print("\tradius1: "); 33 radius1 = input.nextDouble(); 34 if (radius1

3 import java.text.DecimalFormat; 4 import java.util.ArrayList; 5 import java.util.List; 6 /** 7 * 8 * 9 * 10 * 11 * 12 * 13 */ 14 public class ConicalFrustumList { 15 // String variable for List Name 16 private String listName; 17 // List variable for array list 18 private List list; 19 /** 20 *Parameterized Constructor. 21 *@param listNameIn command line arguments not used. 22 *@param listIn command line arguments not used. 23 */ 24 public ConicalFrustumList(String listNameIn, 25 ArrayList listIn) 26 { 27 this.listName = listName; 28 this.list = list; 29 } 30 /** 31 *This method will return the name of the list. 32 *@return something. 33 */ 34 public String getName() 35 { 36 return this.listName; 37 } 38 /** 39 *This method will return the number of 40 Conical Frustum objects available in the list. 41 *@return something. 42 */ 43 public int numberOfConicalFrustum() 44 { 45 return list.size(); 46 } 47 /** 48 *This method will return the total surface area. 49 *@return totalSurfaceArea. 50 */ 51 public double totalSurfaceArea() 52 { 53 double totalSurfaceArea = 0.0; 54 // Iterating through all the Conical Frustum objects present in the list. 55 for (ConicalFrustum tempObj:list) 56 { 57 totalSurfaceArea += tempObj.totalSurfaceArea(); 58 } 59 return totalSurfaceArea; 60 } 61 /** 62 *This method will return total volume. 63 *Iteration used on all objects. 64 *@return totalVolume. 65 */ 66 public double totalVolume() { 67 double totalVolume = 0.0; 68 // Iterating through all the Conical Frustum objects present in the list. 69 for (ConicalFrustum tempObj:list) { 70 totalVolume += tempObj.volume(); 71 } 72 return totalVolume; 73 } 74 /** 75 *This method will return average surface area. 76 *@return something. 77 */ 78 public double averageSurfaceArea() 79 { 80 return list.size() > 0 ? this.totalSurfaceArea() / list.size() : 0.0; 81 } 82 /** 83 *This method will return average volume. 84 *@return something. 85 */ 86 public double averageVolume() 87 { 88 return list.size() > 0 ? this.totalVolume() / list.size() : 0.0; 89 } 90 @Override 91 /** 92 *String buffer to deal with string operations. 93 *This method calls the toString method of ConicalFrustum class 94 for each of the Conical Frustum objects present in the list. 95 * 96 *@return something. 97 *@Override 98 */ 99 public String toString() 100 { 101 StringBuilder sb = new StringBuilder(); 102 sb.append(listName + " List "); 103 for (ConicalFrustum tempObj:list) 104 { 105 sb.append(" " + tempObj.toString() + " "); 106 } 107 return sb.toString(); 108 } 109 /** 110 *This method will return the summary of the list. 111 *@return something. 112 */ 113 public String summaryInfo() 114 { 115 // Using Formatter. 116 DecimalFormat formatter = new DecimalFormat("#,##0.0##"); 117 //StringBuffer to deal with String operations. 118 StringBuilder sb = new StringBuilder(); 119 sb.append("Summary for Conical Frustum Test List "); 120 sb.append("Number of ConicalFrustum Objects: " 121 + list.size() + " "); 122 sb.append("Total Surface Area: " 123 + formatter.format(this.totalSurfaceArea()) + " "); 124 sb.append("Total Volume: " 125 + formatter.format(this.totalVolume()) + " "); 126 sb.append("Average Surface Area: " 127 + formatter.format(this.averageSurfaceArea()) + " "); 128 sb.append("Average Volume: " + formatter.format(this.averageVolume())); 129 return sb.toString(); 130 } 131 } 132 133

Specifications Overview: You will write a program this week that is composed of three classes: the first class defines ConicalFrustum objects, the second class defines ConicalFrustumList objects, and the third, ConicalFrustumListApp, reads in a file name entered by the user then reads the list name and ConicalFrustum data from the file, creates ConicalFrustum objects and stores them in an ArrayList creates a ConicalFrustumList object with the list name and ArrayList, prints the ConicalFrustumList object, and then prints summary information about the ConicalFrustumList object. A Conical Frustum is a Frustum created by slicing the top off a cone (with the cut made parallel to the base), forming a lower base and an upper base that are circular and parallel ri radius of top r2 radius of bottom h height s slant height S lateral surface area V volume A total surface area | S- * (r1 + r2) * s Source for figures and formulas: https://www.calculatorsoup.com/images/frustum001.gif ConicalFrustum.java (assuming that you successfully created this class in Project 4, just copv the file to vour new Project 5 folder and go on to ConicalFrustumList.java on page 4 Otherwise, you will need to create ConicalFrustum.java as part of this project.) Requirements: Create a ConicalFrustum class that stores the label, radius of top, radius of bottom, and height where the radii and height are non-negative. The ConicalFrustum class also includes methods to set and get each of these fields, as well as methods to calculate the volume, slant height, lateral surface area, and total surface area of a ConicalFrustum object, and a method to provide a String value that describes a ConicalFrustum object. Specifications Overview: You will write a program this week that is composed of three classes: the first class defines ConicalFrustum objects, the second class defines ConicalFrustumList objects, and the third, ConicalFrustumListApp, reads in a file name entered by the user then reads the list name and ConicalFrustum data from the file, creates ConicalFrustum objects and stores them in an ArrayList creates a ConicalFrustumList object with the list name and ArrayList, prints the ConicalFrustumList object, and then prints summary information about the ConicalFrustumList object. A Conical Frustum is a Frustum created by slicing the top off a cone (with the cut made parallel to the base), forming a lower base and an upper base that are circular and parallel ri radius of top r2 radius of bottom h height s slant height S lateral surface area V volume A total surface area | S- * (r1 + r2) * s Source for figures and formulas: https://www.calculatorsoup.com/images/frustum001.gif ConicalFrustum.java (assuming that you successfully created this class in Project 4, just copv the file to vour new Project 5 folder and go on to ConicalFrustumList.java on page 4 Otherwise, you will need to create ConicalFrustum.java as part of this project.) Requirements: Create a ConicalFrustum class that stores the label, radius of top, radius of bottom, and height where the radii and height are non-negative. The ConicalFrustum class also includes methods to set and get each of these fields, as well as methods to calculate the volume, slant height, lateral surface area, and total surface area of a ConicalFrustum object, and a method to provide a String value that describes a ConicalFrustum object

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

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions