
what is needed to be solved:
Execute the rectangle class with some modifications:
- add color ------> setter and getter
then upload the source files and screenshoot of the run
//////////////////////////////////////////////////////////////////////////////////
this is a header file:
/// Specification file for the Rectangle class.
#ifndef RECTANGLE_H
#define RECTANGLE_H
/// Rectangle class declaration.
class Rectangle
{
private:
double width;
double length;
string color;
public:
void setWidth(double);
void setLength(double);
void setColor(string);
double getWidth() const;
double getLength() const;
string getColor() const;
double getArea() const;
};
#endif
/////////////////////////////////////////////////////////////////////////////////////
this is a cpp file:
// Implementation file for the Rectangle class.
#include "Rectangle.h" // Needed for the Rectangle class
#include <iostream> // Needed for cout
#include <cstdlib> // Needed for the exit function
using namespace std;
///***********************************************************
/// setWidth sets the value of the member variable width. *
///***********************************************************
void Rectangle::setWidth(double w)
{
if (w >= 0)
width = w;
else
{
cout << "Invalid width\n";
exit(EXIT_FAILURE);
}
}
///***********************************************************
/// setLength sets the value of the member variable length. *
///***********************************************************
void Rectangle::setLength(double len)
{
if (len >= 0)
length = len;
else
{
cout << "Invalid length\n";
exit(EXIT_FAILURE);
}
}
///***********************************************************
/// getWidth returns the value in the member variable width. *
///***********************************************************
double Rectangle::getWidth() const
{
return width;
}
///*************************************************************
/// getLength returns the value in the member variable length. *
///*************************************************************
double Rectangle::getLength() const
{
return length;
}
///************************************************************
/// getArea returns the product of width times length. *
///************************************************************
double Rectangle::getArea() const
{
return width * length;
}

Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 1 images

- JAVA PROGRAM MODIFY AND CHANGE THIS PROGRAM EVEN MORE FOR THE FOLLOWING: IT MUST PASS THE TEST CASE WHEN I UPLOAD IT TO HYPERGRADE. I EVEN CHANGED THE TEXT FILES NAMES. I HAVE ALSO PROVIDED THE BOYMNAMES.TXT AND GIRLNAMES.TXT WHICH ARE INPUTS AND THE FAILED TEST CASES AS A SCREENSHOT. THANK YOU import java.io.*;import java.util.*;public class NameSearcher { private static List<String> loadFileToList(String filename) throws FileNotFoundException { List<String> namesList = new ArrayList<>(); File file = new File(filename); if (!file.exists()) { throw new FileNotFoundException(filename); } try (Scanner scanner = new Scanner(file)) { while (scanner.hasNextLine()) { String line = scanner.nextLine().trim(); String[] names = line.split("\\s+"); for (String name : names) { namesList.add(name.toLowerCase()); } } }…arrow_forwardIm trying ro read a csv file and store it into a 2d array but im getting an error when I run my java code. my csv file contains 69 lines of data Below is my code: import java.util.Scanner; import java.util.Arrays; import java.util.Random; import java.io.File; import java.io.FileNotFoundException; import java.io.FilenameFilter; public class CompLab2 { public static String [][] getEarthquakeDatabase (String Filename) { //will read the csv file and convert it to a string 2-d array String [][] Fileinfo = new String [69][22]; int counter = 0; File file = new File(Filename); try { Scanner scnr = new Scanner(file); scnr.nextLine(); //skips the label in the first row of the file while (scnr.hasNextLine()) { // this while loop will count the number of values in the usgs file counter += 1; // increases by one each time a line is read scnr.nextLine(); } while…arrow_forwardI am trying to read a CSV file and then store it into an ArrayList. For each row, I'm trying to create a new Country class instance and add it to the list. However, it is giving me the following as the output: edu.uga.cs1302.quiz.Country@7c9bb6b8 edu.uga.cs1302.quiz.Country@441847 edu.uga.cs1302.quiz.Country@2621fba7 edu.uga.cs1302.quiz.Country@4fa6e7a1 edu.uga.cs1302.quiz.Country@6e29b69b edu.uga.cs1302.quiz.Country@4e0f0d39 edu.uga.cs1302.quiz.Country@67da3b9c edu.uga.cs1302.quiz.Country@1f394329 edu.uga.cs1302.quiz.Country@3c07b33b edu.uga.cs1302.quiz.Country@a570747 edu.uga.cs1302.quiz.Country@3ce7cb4a edu.uga.cs1302.quiz.Country@6912e7f4 edu.uga.cs1302.quiz.Country@680d0f86 edu.uga.cs1302.quiz.Country@5a5250ff edu.uga.cs1302.quiz.Country@58ed7d64 edu.uga.cs1302.quiz.Country@26be1cca edu.uga.cs1302.quiz.Country@26cf56a4 edu.uga.cs1302.quiz.Country@6ed22f2a edu.uga.cs1302.quiz.Country@5de769c9 edu.uga.cs1302.quiz.Country@b6966f3 edu.uga.cs1302.quiz.Country@574f6b4c…arrow_forward
- Make a class for rectangle which calculates perimeter and area by doing following: use the dynamic allocation. has a default constructor has a destructor. use an array of objects for 5 different rectangles make a UML upload 3 files as class (.h) main function (.cpp) UML(pdf)arrow_forwardWhat are the Javadoc comments for each class? I am strugglingarrow_forwardYou have to use comment function to describe what each line does import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class PreferenceData { private final List<Student> students; private final List<Project> projects; private int[][] preferences; private static enum ReadState { STUDENT_MODE, PROJECT_MODE, PREFERENCE_MODE, UNKNOWN; }; public PreferenceData() { super(); this.students = new ArrayList<Student>(); this.projects = new ArrayList<Project>(); } public void addStudent(Student s) { this.students.add(s); } public void addStudent(String s) { this.addStudent(Student.createStudent(s)); } public void addProject(Project p) { this.projects.add(p); } public void addProject(String p) { this.addProject(Project.createProject(p)); } public void createPreferenceMatrix() { this.preferences = new…arrow_forward
- Which of these best describes an array? a. A data structure that shows a hierarchical behavior b. Container of objects of similar types C. Container of objects of mixed types d. All of the mentionedarrow_forwardhow would you do this in a simple way? this is a non graded practice labarrow_forwardImage one is the example output of text-based histogram . Image 2 is my file. You can creat a new file too(up to u) as long as the output shows the times of appearances of the numbers. (Like the example showed in image 1, if number 20 appeared 1 times, print 1 star after it. I want to write: A method to print a text-based histogram takes one parameter, an array of integers no return valuearrow_forward
- Java Program ASAP I want only one program. Please pay attention to the screenshot for test case 2 and 3 and please make sure you match the result. Modify this program so it passes the test cases in Hypergrade becauses it says 5 out of 7 passed. import java.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.util.ArrayList;import java.util.Arrays;import java.util.InputMismatchException;import java.util.Scanner;public class FileSorting { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (true) { System.out.println("Please enter the file name or type QUIT to exit:"); String fileName = scanner.nextLine(); if (fileName.equalsIgnoreCase("QUIT")) { break; } try { ArrayList<String> lines = readFile(fileName); if (lines.isEmpty()) { System.out.println("File " + fileName + " is…arrow_forwardTwo objects of the same class, say "mylnstance1" and "mylnstance2", are declared in a program as a collection of some type (say an ArrayList). mylnstance1 is initialized but mylnstance2 is not. Then mylnstance1 is copied to mylnstance2. If the copy is performed as a copy constructor copy, two collections exist after the copy but the two collections share all the same elements.arrow_forwardPlease help me with this questionarrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





