I need help: Please help me correct it the mistake I keep receiving this error:  TestFrame1.java:29: error: count has private access in Frame System.out.println("Total number of frames created: " + frame.count); 1 error.  Below is the code: import java.util.Scanner; public class TestFrame1 {    // Scanner class instance     private static Scanner scanner;     // Main() public static void main(String[] args) { scanner = new Scanner(System.in); //make frame Frame frame = makeFrame(); //calc cost double cost = calcCost(frame); // Display frame attributes and cost System.out.println(frame); System.out.println(String.format("Total cost of frame: $%.2f", cost)); // Prompt user to buy another desk System.out.println("Do you want to buy another desk? (y/n)"); String input = scanner.next(); // If yes, then repeat above steps if (input.toLowerCase().equals("y")) { frame = makeFrame(); double cost2 = calcCost(frame); cost += cost2; System.out.println("Total number of frames created: " + frame.count); System.out.println(String.format("Total cost of pictures: $%.2f", cost)); System.out.println(String.format("Average picture cost: $%.2f",cost / 2)); } // End program System.out.println("See you later Alligator!"); } // Method to create a frame private static Frame makeFrame() { scanner = new Scanner(System.in); // Prompt user to enter length, width, type, matte System.out.print("Please enter the length: "); float length = scanner.nextFloat(); System.out.print("Please enter the width: "); float width = scanner.nextFloat(); System.out.print("Please enter the type: P, W or M "); char type = scanner.next().charAt(0); //convert type to uppercase Character.toUpperCase(type); // Validate type if (type != 'P' && type != 'W' && type != 'M') { type = 'W'; } System.out.print("Please enter the number of matte: "); int matte = scanner.nextInt(); // Create a Frame class object with all the values Frame frame = new Frame(length, width, type, matte); return frame; } // Method to calculate price of a picture     public static double calcCost(Frame frame) { // Initialize price double cost = 0; // Store and check type of frame, update price accordingly char type = frame.getType(); if (type == 'P') { cost += 10.00; } else if (type == 'W') { cost += 22; } else {cost += 31;} // Store area of frame double area = frame.getArea(); // If area is greater than 100, update price if (area > 100) { cost += 12.50; } // If matte is greater than 5, add 5 if (frame.getMatte() > 5) { cost += 5 * 7.25; } //else add cost of matte else { cost += frame.getMatte() * 7.25; } // Return cost         return cost; } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I need help: Please help me correct it the mistake

I keep receiving this error: 

TestFrame1.java:29: error: count has private access in Frame
System.out.println("Total number of frames created: " + frame.count);
1 error. 

Below is the code:

import java.util.Scanner;

public class TestFrame1 {
   // Scanner class instance
    private static Scanner scanner;

    // Main()
public static void main(String[] args) {
scanner = new Scanner(System.in);

//make frame
Frame frame = makeFrame();
//calc cost
double cost = calcCost(frame);

// Display frame attributes and cost
System.out.println(frame);
System.out.println(String.format("Total cost of frame: $%.2f", cost));

// Prompt user to buy another desk
System.out.println("Do you want to buy another desk? (y/n)");
String input = scanner.next();

// If yes, then repeat above steps
if (input.toLowerCase().equals("y")) {
frame = makeFrame();
double cost2 = calcCost(frame);
cost += cost2;
System.out.println("Total number of frames created: " + frame.count);
System.out.println(String.format("Total cost of pictures: $%.2f", cost));
System.out.println(String.format("Average picture cost: $%.2f",cost / 2));
}

// End program
System.out.println("See you later Alligator!");
}

// Method to create a frame
private static Frame makeFrame() {
scanner = new Scanner(System.in);

// Prompt user to enter length, width, type, matte
System.out.print("Please enter the length: ");
float length = scanner.nextFloat();
System.out.print("Please enter the width: ");
float width = scanner.nextFloat();
System.out.print("Please enter the type: P, W or M ");
char type = scanner.next().charAt(0);

//convert type to uppercase
Character.toUpperCase(type);

// Validate type
if (type != 'P' && type != 'W' && type != 'M') {
type = 'W';
}
System.out.print("Please enter the number of matte: ");
int matte = scanner.nextInt();

// Create a Frame class object with all the values
Frame frame = new Frame(length, width, type, matte);

return frame;
}

// Method to calculate price of a picture
    public static double calcCost(Frame frame) {

// Initialize price
double cost = 0;

// Store and check type of frame, update price accordingly
char type = frame.getType();
if (type == 'P') {
cost += 10.00;
}
else if (type == 'W') {
cost += 22;
}
else {cost += 31;}

// Store area of frame
double area = frame.getArea();

// If area is greater than 100, update price
if (area > 100) {
cost += 12.50;
}

// If matte is greater than 5, add 5
if (frame.getMatte() > 5) {
cost += 5 * 7.25;
}

//else add cost of matte
else {
cost += frame.getMatte() * 7.25;
}
// Return cost
        return cost;
}
}

 

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Adjacency Matrix
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education