Question
This has to be extremely precise, thank you for your time.
ols Window Help U + 1 /write a class meeting the following specifications: 3 //The class is declared as public. 4 //The class
ols Window Help 7 //The class has a field of type double named film, 8 //The class has a exactly one constructor 9 //The cons
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program:

Country.java

public class Country {
    private String anger;
    private int stretch;
    private double film;

    public Country(String anger, int stretch, double film) {
        this.anger = anger;
        this.stretch = stretch;
        this.film = film;
    }

    public String getAnger() {
        return anger;
    }

    public void setAnger(String anger) {
        this.anger = anger;
    }

    public int getStretch() {
        return stretch;
    }

    public void setStretch(int stretch) {
        this.stretch = stretch;
    }

    public double getFilm() {
        return film;
    }

    public void setFilm(double film) {
        this.film = film;
    }

    @Override
    public String toString() {
        return "Country{" + "anger=" + anger + ", stretch=" + stretch + ", film=" + film + '}';
    }
  
}


TestCountry.java

import static java.lang.System.exit;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class TestCountry {

    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
       String controlString;
       List<Country> lineArrayList= new ArrayList<>();
       do{
            System.out.println("Enter a control String: ");
            controlString= sc.next();
     
           if(controlString.equalsIgnoreCase("party"))
            {
                exit(0);
            }
           else if(controlString.equalsIgnoreCase("lake"))
            {
                for (Country country : lineArrayList) {
                    System.out.println(country.toString());         
                }
            }
           else if(controlString.equalsIgnoreCase("raspy"))
            {
                String anger;
                int stretch;
                double film;
                System.out.println("Enter enter a String value : ");
                anger=sc.next();
                System.out.println("Enter enter a int value : ");
                stretch=sc.nextInt();
                System.out.println("Enter enter a double value : ");
                film=sc.nextDouble();
                Country country= new Country(anger, stretch, film);
                lineArrayList.add(country);
            }
           else if(controlString.equalsIgnoreCase("sky"))
            {
                String searchString;
              
                System.out.println("Enter enter a String value : ");
                searchString= sc.next();
                for (Country country : lineArrayList) {
                        if(country.getAnger().endsWith(searchString))
                        {
                            System.out.println(country.toString());
                        }
                    }
            }
       }while(true);
     
     
    }
  
}


Output:

Output - CheggClasses (run) x run: Enter a control String: raspy Enter enter a String value: fresco Enter enter a int value :

.

Add a comment
Know the answer?
Add Answer to:
This has to be extremely precise, thank you for your time. ols Window Help U +...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • please write in Java and include the two classes Design a class named Fan (Fan.java) to...

    please write in Java and include the two classes Design a class named Fan (Fan.java) to represent a fan. The class contains: An int field named speed that specifies the speed of the fan. A boolean field named fanStatus that specifies whether the fan is on (default false). A double field named radius that specifies the radius of the fan (default 5). A string field named color that specifies the color of the fan (default blue). A no-arg (default) constructor...

  • You will turn in a java file named "MyMethods.java". It will contain one class named "MyMethods". That class will contain three methods. These methods must be in JOptionPane and must c...

    You will turn in a java file named "MyMethods.java". It will contain one class named "MyMethods". That class will contain three methods. These methods must be in JOptionPane and must contain: getAnInt will return a value of type int, and take as an argument a string to prompt the user. The actual prompt presented to the user should include not only the string argument, but also the information that the user may press Cancel or enter an empty string to...

  • This assignment will continue our hardware store system. You will turn in a java file named...

    This assignment will continue our hardware store system. You will turn in a java file named "MyMethods.java". It will contain one class named "MyMethods". That class will contain three methods. These methods must be exactly as specified (including method names): getAnInt will return a value of type int, and take as an argument a string to prompt the user. The actual prompt presented to the user should include not only the string argument, but also the information that the user...

  • Please help with this assignment. Thanks. 1. Write a C++ program containing a class Invoice and...

    Please help with this assignment. Thanks. 1. Write a C++ program containing a class Invoice and a driver program called invoiceDriver.cpp. The class Invoice is used in a hardware store to represent an invoice for an item sold at the store. An invoice class should include the following: A part number of type string A part description of type string A quantity of the item being purchased of type int A price per item of type int A class constructor...

  • The purpose of this is to use inheritance, polymorphism, object comparison, sorting, reading binary files, and...

    The purpose of this is to use inheritance, polymorphism, object comparison, sorting, reading binary files, and writing binary files. In this application you will modify a previous project. The previous project created a hierarchy of classes modeling a company that produces and sells parts. Some of the parts were purchased and resold. These were modeled by the PurchasedPart class. Some of the parts were manufactured and sold. These were modeled by the ManufacturedPart class. In this you will add a...

  • Hi. Could you help me with the code below? I need to validate the code below, using expressions that can carry out the actions or that make appropriate changes to the program’s state, using conditiona...

    Hi. Could you help me with the code below? I need to validate the code below, using expressions that can carry out the actions or that make appropriate changes to the program’s state, using conditional and iterative control structures that repeat actions as needed. The unit measurement is missing from the final output and I need it to offer options to lbs, oz, grams, tbsp, tsp, qt, pt, and gal. & fl. oz. Can this be added? The final output...

  • Download PartiallyFilledArray.java. Though we studied this in class, you should still take several minutes examining the...

    Download PartiallyFilledArray.java. Though we studied this in class, you should still take several minutes examining the code so that you understand the methods of the class. /** * This is a solution to the lab, "partially filled array". * * * */ import java.util.Scanner; public class CalculateAverage { public static void main(String[] args){ PartiallyFilledArray data = new PartiallyFilledArray(); getInput(data); printResults(data); }    private static void getInput(PartiallyFilledArray data) { Scanner kbd = new Scanner(System.in); System.out.print("Enter a number (negative will end input):");...

  • Additional info is this will use a total of four classes Book, BookApp, TextBook, and TextBookApp....

    Additional info is this will use a total of four classes Book, BookApp, TextBook, and TextBookApp. Also uses Super in the TextBook Class section. Problem 1 (10 points) Вook The left side diagram is a UML diagram for Book class. - title: String The class has two attributes, title and price, and get/set methods for the two attributes. - price: double Вook) Book(String, double) getTitle(): String setTitle(String): void + getPrice() double setPrice(double): void toString() String + The first constructor doesn't...

  • Game Development: Uno For this assignment you will be creating the game of Uno (See the...

    Game Development: Uno For this assignment you will be creating the game of Uno (See the accompanying pdf for the instructions of the game). Your version will adhere to all the rules except that only the next player can issue a challenge against the previous player in regards to penalties, and your games must have at least three (3) players and at most nine (9) players. To begin, you must create the class Card which contains: Private string field named...

  • Implement a Java program using simple console input & output and logical control structures such that...

    Implement a Java program using simple console input & output and logical control structures such that the program prompts the user to enter 5 integer scores between 0 to 100 as inputs and does the following tasks For each input score, the program determines whether the corresponding score maps to a pass or a fail. If the input score is greater than or equal to 60, then it should print “Pass”, otherwise, it should print “Fail”. After the 5 integer...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT