Which of the following statements are true about the code shown below in the class named Quiz? (Select all that apply.)

public class Quiz {
public static void printOdd(int n) {
for(int i = 0; i < n; i++){
if(i % 2 != 0)
System.out.println(i);
else
System.out.println(i+1);
}
}

public static void main(String arg[]) {
printOdd(5);
}
}

a. A value of 5 will be substituted for the parameter during the execution of the printOdd method.
b. This method will print a list of all even numbers less than n.
c. This method when executed as called by main will print out 5 lines of output.
d. This method when executed as called by main will print out 1 line of output.
e. A value of 5 is being returned to main from the printOdd method after execution.

Answers

Answer 1

Answer:

a. and c.

Explanation:

The snippet of code provided will print out all of the odd numbers between 0 and the value passed as a parameter. If a number is even, it will add 1 to the even number and print out the new value. Therefore, there will be a total of outputs as the number passed as an argument. For example, this code will output a total of 5 lines of output. Therefore, the statements that would be true in this question would be the following...

a. A value of 5 will be substituted for the parameter during the execution of the printOdd method.

c. This method when executed as called by main will print out 5 lines of output.


Related Questions

d) State any three (3) reasons why users attach speakers to their computer?​

Answers

Answer:

the purpose of speakers is to produce audio output that can be heard by the listener. Speakers are transducers that convert electromagnetic waves into sound waves. The speakers receive audio input from a device such as a computer or an audio receiver.

Explanation: Hope this helps!

Parts of a computer software

Answers

Answer:

I think application software

utility software

networking software

What is the first thing you should do when you discover a computer is infected with malware? The second thing?

Answers

Answer:

Quarantine the computer.

Explanation:

Malware can be characterized with negative software capable of causing various damages to a computer, such as theft of data and information, in addition to damage to devices.

In order to avoid having your computer infected with malware, it is essential to have installed reliable malware-checking software, in addition to taking all appropriate security measures when accessing the internet and never clicking on unknown or suspicious links.

Therefore, when realizing that the computer has been infected by malware, it is necessary to quarantine the computer and immediately disconnect from a network so that it does not infect other computers. The quarantine acts as an action where the infected file is moved to an encrypted folder where the malware cannot be executed and spread by the operating system.

what is the role of computer in modern problem solving​

Answers

Answer:

Una computadora es una herramienta muy básica para hacer tareas repetitivas de forma más eficiente. Una computadora no es capaz de analizar un problema y obtener una solución.

Explanation:

Instructions: Use the tables below to answer the questions that follow:
Total Points
12
Table 1.1
Age
16
1234
1356
1254
1334
Name
Charles
Junior
Carla
Josie
STUDENTS
Class
Gender
3B
Female
35
Male
35
Female
3B
Female
20
21
Payment
$28.00
$32.00
$44.00
$50.00
18
1. State the data type that would be most suitable to use for: (6pts)
a. Class
b. Age
2. How
How many records are in the table?
3. Identify 2 examples of field names in the table above. (4pts)
c. Payment
(2pts)
a.
b.​

Answers

Answer:

1.B

sorry po yan lang alam ko eh sorrt

Explanation:

brainelst po

For two integers m and n, their GCD(Greatest Common Divisor) can be computed by a recursive function. Write a recursive method gcd(m,n) to find their Greatest Common Divisor. Once m is 0, the function returns n. Once n is 0, the function returns m. If neither is 0, the function can recursively calculate the Greatest Common Divisor with two smaller parameters: One is n, the second one is m mod n. Although there are other approaches to calculate Greatest Common Divisor, your program should follow the instructions of this question, otherwise you will not get the credit. Then write a testing program to call the recursive method.

Answers

Answer:

In Python:

def gcd(m,n):

if n == 0:

 return m

elif m == 0:

    return n

else:

 return gcd(n,m%n)

Explanation:

This defines the function

def gcd(m,n):

If n is 0, return m

if n == 0:

 return m

If m is 0, return n

elif m == 0:

    return n

If otherwise, calculate the gcd recursively

else:

 return gcd(n,m%n)

To call the function to calculate the gcd of say 15 and 5 from main, use:

gcd(15,5)

1-(50 points) The function sum_n_avgcomputes the sum and the average of three input arguments and relays its results through two output parameters.a)Write a prototype for a function sum_n_avgthat accepts three double-type inputparameters and returns two output parameters through reference.b)Write the function definition for function sum_n_avg. The function definition is where the actual computations are performed.c)Write a function call in main ()forsum_n_avg. The function call can look like below free

Answers

Answer:

The program in C++ is as follows:

#include <iostream>

using namespace std;

double *sum_n_avg(double n1, double n2, double n3);

int main () {

   double n1, n2, n3;

   cout<<"Enter 3 inputs: ";

   cin>>n1>>n2>>n3;

   double *p;

   p = sum_n_avg(n1,n2,n3);

   cout<<"Sum: "<<*(p + 0) << endl;

   cout<<"Average: "<<*(p + 1) << endl;

  return 0;

}

double *sum_n_avg(double n1, double n2, double n3) {

  static double arr[2];

  arr[0] = n1 + n2 + n3;

  arr[1] = arr[0]/3;

  return arr;

}

Explanation:

This defines the function prototype

double *sum_n_avg(double n1, double n2, double n3);

The main begins here

int main () {

This declares variables for input

   double n1, n2, n3;

This prompts the user for 3 inputs

   cout<<"Enter 3 inputs: ";

This gets user inputs

   cin>>n1>>n2>>n3;

This declares a pointer to get the returned values from the function

   double *p;

This passes n1, n2 and n3 to the function and gets the sum and average, in return.

   p = sum_n_avg(n1,n2,n3);

Print sum and average

   cout<<"Sum: "<<*(p + 0) << endl;

   cout<<"Average: "<<*(p + 1) << endl;

  return 0;

}

The function begins here

double *sum_n_avg(double n1, double n2, double n3) {

Declare a static array

  static double arr[2];

Calculate sum

  arr[0] = n1 + n2 + n3;

Calculate average

  arr[1] = arr[0]/3;

Return the array to main

  return arr;

}

What are some examples and non-examples of digital etiquette?

Answers

Answer:

saying hello to strangers and standing up to cyber bullies

using all caps. cyber bullying. cursing. stalking

dont download that file

IPSec or internet Protocol Security is an extension of the Internet Protocol. What does IPSec use to provide network security?

Answers

Answer:

In computing, Internet Protocol Security ( IPSec ) is a secure network protocol suite that authenticates and encrypts the packets of data to provide secure encrypted communication between two computers over on internet protocol network. It is used in virtual private networks ( VPNs ).

what should the timing of transition slides be per minute? maintain the flow of the presentation to ______ slides per minute.

Answers

Answer:

1-2

Explanation:

It depends on the amount of information that you have on each slide. You want to make sure you're not going too fast but also make sure you arent taking up to much time. Be sure to speak clearly it will make the presentation better by looking clean and time organized. hope this helps :)

what are the different methods of enhancing/decorating
bamboo product​

Answers

Explanation:

Methods of this technique include glueing, chemical gilding, and electroplating.  Staining is used to color wood to give an illusion of texture. This may come in two varieties.

Note that common skills are listed toward the top, and less common skills are listed toward the bottom. According to O*NET, what are common skills needed by Secondary School Special Education Teachers? Check all that apply.

instructing
installation
learning strategies
repairing
active listening
technology design

Answers

Answer:

A. Instucting   C. Learning Strategies   E. Active Listening

Explanation:

Got it right on assignment

Draw a flowchart to compute sum A=10 & B=20​

Answers

Answer: i add the asnwer

Explanation:

Phone numbers and PIN codes can be easier to remember when you find words that spell out the number on a standard phone keypad. For example, instead of remembering the combination 2633, you can just think of CODE. Write a recursive function that, given a number, yields all possible spellings (which may or may not be real words).

Answers

Answer:

Explanation:

The following is written in Python and the code first creates a simulated keypad with all the characters. Then the function detects the number passed as an input argument and outputs all the possible spelling combinations.

keypad = {

   '2': 'abc',

   '3': 'def',

   '4': 'ghi',

   '5': 'jkl',

   '6': 'mno',

   '7': 'pqrs',

   '8': 'tuv',

   '9': 'wxyz',

}

def word_numbers(number):

 number = str(number)

 wordList = ['']

 for char in number:

   letters = keypad.get(char, '')

   wordList = [prefix+letter for prefix in wordList for letter in letters]

 return wordList

does anyone play r0bIox

Answers

Answer:

Ah, okay okay, I know that game seems like a MEME, but it's actually good. I know a lot of kids play it and this community is filled with people...


What sort of query is (strbucks]?


Answers

Starbucks as understood

SimpleScalar is an architectural simulator which enables a study of how different pro-cessor and memory system parameters affect performance and energy efficiency.

a. True
b. False

Answers

Answer:

a. True

Explanation:

SimpleScalar refers to a computer architectural simulating software application or program which was designed and developed by Todd Austin at the University of Wisconsin, Madison, United States of America. It is an open source simulator written with "C" programming language and it's used typically for modelling virtual computer systems having a central processing unit (CPU), memory system parameters (hierarchy), and cache.

The main purpose of SimpleScalar is to avail developers or manufacturers the ability to compare two computers based on their capacities (specifications) without physically building the two computers i.e using a simulation to show or illustrate that computer B is better than computer A, without necessarily having to physically build either of the two computers.

Hence, it is an architectural simulator which makes it possible to study how different central processing units (CPUs), memory hierarchy or system parameters and cache affect the performance and energy efficiency of a computer system.

the importance of optimizing a code

Answers

Answer:

Definition and Properties. Code optimization is any method of code modification to improve code quality and efficiency. A program may be optimized so that it becomes a smaller size, consumes less memory, executes more rapidly, or performs fewer input/output operations.

your computer has been running slowly and you suspect it because its is low on memory. you review the hardware configuration and find that computer has only 4gb of ram. how can you determine how much memory your computer should have to run properly?​

Answers

By downloading software that is capable of checking live Ram usage/need. GIVE BRAINLIST

....is the process whereby you transfer a file from your computer to the Internet.​

Answers

File transfer protocol is the process whereby you transfer a file from your computer to the Internet.​

Answer:

A post is the process whereby you transfer a file from your computer to the Internet.​

Explanation:

Usually, when you post something from the internet, you would get a file from your device, and then post it by the way of your choice. For example, let's say I'm asking a question on Brainly, and I want to post a picture of a graph of a linear function. I would have to get the saved photo from my computer, upload it to the Brainly, and click "ASK YOUR QUESTION". So, a post is the process whereby you transfer a file from your computer to the Internet.​ Hope this helps!

⡯⡯⡾⠝⠘⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢊⠘⡮⣣⠪⠢⡑⡌
⠀⠀⠀⠟⠝⠈⠀⠀⠀⠡⠀⠠⢈⠠⢐⢠⢂⢔⣐⢄⡂⢔⠀⡁⢉⠸⢨⢑⠕⡌
⠀⠀⡀⠁⠀⠀⠀⡀⢂⠡⠈⡔⣕⢮⣳⢯⣿⣻⣟⣯⣯⢷⣫⣆⡂⠀⠀⢐⠑⡌
⢀⠠⠐⠈⠀⢀⢂⠢⡂⠕⡁⣝⢮⣳⢽⡽⣾⣻⣿⣯⡯⣟⣞⢾⢜⢆⠀⡀⠀⠪
⣬⠂⠀⠀⢀⢂⢪⠨⢂⠥⣺⡪⣗⢗⣽⢽⡯⣿⣽⣷⢿⡽⡾⡽⣝⢎⠀⠀⠀⢡
⣿⠀⠀⠀⢂⠢⢂⢥⢱⡹⣪⢞⡵⣻⡪⡯⡯⣟⡾⣿⣻⡽⣯⡻⣪⠧⠑⠀⠁⢐
⣿⠀⠀⠀⠢⢑⠠⠑⠕⡝⡎⡗⡝⡎⣞⢽⡹⣕⢯⢻⠹⡹⢚⠝⡷⡽⡨⠀⠀⢔
⣿⡯⠀⢈⠈⢄⠂⠂⠐⠀⠌⠠⢑⠱⡱⡱⡑⢔⠁⠀⡀⠐⠐⠐⡡⡹⣪⠀⠀⢘
⣿⣽⠀⡀⡊⠀⠐⠨⠈⡁⠂⢈⠠⡱⡽⣷⡑⠁⠠⠑⠀⢉⢇⣤⢘⣪⢽⠀⢌⢎
⣿⢾⠀⢌⠌⠀⡁⠢⠂⠐⡀⠀⢀⢳⢽⣽⡺⣨⢄⣑⢉⢃⢭⡲⣕⡭⣹⠠⢐⢗
⣿⡗⠀⠢⠡⡱⡸⣔⢵⢱⢸⠈⠀⡪⣳⣳⢹⢜⡵⣱⢱⡱⣳⡹⣵⣻⢔⢅⢬⡷
⣷⡇⡂⠡⡑⢕⢕⠕⡑⠡⢂⢊⢐⢕⡝⡮⡧⡳⣝⢴⡐⣁⠃⡫⡒⣕⢏⡮⣷⡟
⣷⣻⣅⠑⢌⠢⠁⢐⠠⠑⡐⠐⠌⡪⠮⡫⠪⡪⡪⣺⢸⠰⠡⠠⠐⢱⠨⡪⡪⡰
⣯⢷⣟⣇⡂⡂⡌⡀⠀⠁⡂⠅⠂⠀⡑⡄⢇⠇⢝⡨⡠⡁⢐⠠⢀⢪⡐⡜⡪⡊
⣿⢽⡾⢹⡄⠕⡅⢇⠂⠑⣴⡬⣬⣬⣆⢮⣦⣷⣵⣷⡗⢃⢮⠱⡸⢰⢱⢸⢨⢌
⣯⢯⣟⠸⣳⡅⠜⠔⡌⡐⠈⠻⠟⣿⢿⣿⣿⠿⡻⣃⠢⣱⡳⡱⡩⢢⠣⡃⠢⠁
⡯⣟⣞⡇⡿⣽⡪⡘⡰⠨⢐⢀⠢⢢⢄⢤⣰⠼⡾⢕⢕⡵⣝⠎⢌⢪⠪⡘⡌⠀
⡯⣳⠯⠚⢊⠡⡂⢂⠨⠊⠔⡑⠬⡸⣘⢬⢪⣪⡺⡼⣕⢯⢞⢕⢝⠎⢻⢼⣀⠀
⠁⡂⠔⡁⡢⠣⢀⠢⠀⠅⠱⡐⡱⡘⡔⡕⡕⣲⡹⣎⡮⡏⡑⢜⢼⡱⢩⣗⣯⣟
⢀⢂⢑⠀⡂⡃⠅⠊⢄⢑⠠⠑⢕⢕⢝⢮⢺⢕⢟⢮⢊⢢⢱⢄⠃⣇⣞⢞⣞⢾
⢀⠢⡑⡀⢂⢊⠠⠁⡂⡐⠀⠅⡈⠪⠪⠪⠣⠫⠑⡁⢔⠕⣜⣜⢦⡰⡎⡯⡾⡽

Answers

Answer:

nice................

Answer:

24

Explanation:

Create a script that will determine how many of each currency type are needed to make change for a given amount of dollar and cents. Input Asks the user for a dollar and cents amount as a single decimal number. Output The program should indicate how many of each of these are needed for the given amount: $20 bills $10 bills $5 bills $1 bills Quarters ($0.25 coin) Dimes ($0.10 coin) Nickels ($0.05 coin) Pennies ($0.01 coin) If a dollar or coin is not needed (its quantity required is 0), do not print it.

Answers

Answer:

The program in Python is as follows:

dollar = float(input("Dollars: "))

t20bill = int(dollar//20)

dollar -= t20bill * 20

t10bill = int(dollar//10)

dollar -= t10bill * 10

t5bill = int(dollar//5)

dollar -= t5bill * 5

t1bill = int(dollar//1)

dollar-= t1bill * 1

qtr = int(dollar//0.25)

dollar -= qtr * 0.25

dime = int(dollar//0.10)

dollar -= dime * 0.10

nkl = int(dollar//0.05)

dollar -= nkl * 0.05

pny = round(dollar/0.01)

if t20bill != 0:    print(t20bill,"$20 bills")

if t10bill != 0:    print(t10bill,"$10 bills")

if t5bill != 0:    print(t5bill,"$5 bills")

if t1bill != 0:    print(t1bill,"$1 bills")

if qtr != 0:    print(qtr,"quarters")

if dime != 0:    print(dime,"dimes")

if nkl != 0:    print(nkl,"nickels")

if pny != 0:    print(pny,"pennies")

Explanation:

This gets input for dollars

dollar = float(input("Dollars: "))

Calculate the number of $20 bills

t20bill = int(dollar//20)

Calculate the remaining dollars

dollar -= t20bill * 20

Calculate the number of $10 bills

t10bill = int(dollar//10)

Calculate the remaining dollars

dollar -= t10bill * 10

Calculate the number of $5 bills

t5bill = int(dollar//5)

Calculate the remaining dollars

dollar -= t5bill * 5

Calculate the number of $1 bills

t1bill = int(dollar//1)

Calculate the remaining dollars

dollar-= t1bill * 1

Calculate the number of quarter coins

qtr = int(dollar//0.25)

Calculate the remaining dollars

dollar -= qtr * 0.25

Calculate the number of dime coins

dime = int(dollar//0.10)

Calculate the remaining dollars

dollar -= dime * 0.10

Calculate the number of nickel coins

nkl = int(dollar//0.05)

Calculate the remaining dollars

dollar -= nkl * 0.05

Calculate the number of penny coins

pny = round(dollar/0.01)

The following print the number of bills or coins. The if statement is used to prevent printing of 0

if t20bill != 0:    print(t20bill,"$20 bills")

if t10bill != 0:    print(t10bill,"$10 bills")

if t5bill != 0:    print(t5bill,"$5 bills")

if t1bill != 0:    print(t1bill,"$1 bills")

if qtr != 0:    print(qtr,"quarters")

if dime != 0:    print(dime,"dimes")

if nkl != 0:    print(nkl,"nickels")

if pny != 0:    print(pny,"pennies")

Create a class to represent light bulbs
Create a class called Bulb that will represent a light bulb. It should have instance variables for the manufacturer (String), part number (String), wattage (int) and lumens (int). Get and Set methods should be included. Override the equals and to String methods from class Object.
List of Bulbs
Create a class called BulbNode which has fields for the data (a Bulb) and next (BulbNode) instance variables. Include a one-argument constructor which takes a Bulb as a parameter. (For hints, see the PowerPoint on "Static vs. Dynamic Structures".)
public BulbNode (Bulb b) {...}
The instance variables should have protected access. There will not be any get and set methods for the two instance variables.
Create an abstract linked list class called BulbList. This should be a linked list with head node as described in lecture. Modify it so that the data type in the nodes is Bulb. The no-argument constructor should create an empty list with first and last pointing to an empty head node, and length equal to zero. Include an append method in this class.
Create two more linked list classes that extend the abstract class BulbList: One called UnsortedBulbList and one called SortedBulbList, each with appropriate no-argument constructors. Each of these classes should have a method called add(Bulb) that will add a new node to the list. In the case of the UnsortedBulbList it will add it to the end of the list by calling the append method in the super class. In the case of the SortedBulbList it will insert the node in the proper position to keep the list sorted by wattage.
Instantiate two linked lists, and for every Bulb read from the file, add it to the unsorted and sorted lists using the add method. You will end up with the first list having the Bulbs from the input file in the order they were read, and in the second list the Bulbs will be in sorted order.
Display the unsorted and sorted Bulbs in a GUI with a GridLayout of one row and two columns. Put the unsorted Bulbs in the left column, and the sorted Bulbs in the right column.
The input file
There will be an input file provided on Blackboard which contains information about bulbs, one per line, with the manufacturer, part number, wattage and lumens separated by commas, such as:
Phillips, 1237DF2, 100, 1200
You can separate the four items using a StringTokenizer.
Submitting the Project.
You should now have the following files to submit for this project:
Project2.java
Bulb.java
BulbGUI.java
BulbNode.java
BulbList.java
UnsortedBulbList.java
SortedBulblist.java
Submit a jar file.
Rather than upload all the files above separately, we will use Java's facility to create the equivalent of a zip file that is known as a Java Archive file, or "jar" file.
Instructions on how to create a jar file using Eclipse are on Blackboard. Create a jar file called Project2.jar and submit that. Be sure the jar file contains source code, not classes.

Answers

Answer:

umm

Explanation:

Can someone please help me I will mark u brilliant

Answers

Answer: “Frame rate (expressed in frames per second or FPS) is the frequency (rate) at which consecutive images called frames appear on a display. The term applies equally to film and video cameras, computer graphics, and motion capture systems. Frame rate may also be called the frame frequency, and be expressed in hertz” this is what I searched up and maybe you can see what’s similar

Explanation: I think it’s yellow

Answer: The answer is the first box, the rate at which frames in an animation are shown, typically measured in frames per second.

Expain how central processing unit function? ​

Answers

Answer:

Answer of CPU

Explanation:

Central Processing Unit (CPU) consists of the following features − CPU is considered as the brain of the computer. CPU performs all types of data processing operations. It stores data, intermediate results, and instructions (program). It controls the operation of all parts of the computer.

Answer:

A central processing unit (CPU), also called a central processor, main processor or just processor, is the electronic circuitry that executes instructions comprising a computer program.

3. Write a program to find the area of a triangle using functions. a. Write a function getData() for user to input the length and the perpendicular height of a triangle. No return statement for this function. b. Write a function trigArea() to calculate the area of a triangle. Return the area to the calling function. c. Write a function displayData() to print the length, height, and the area of a triangle ( use your print string) d. Write the main() function to call getData(), call trigArea() and call displayData().

Answers

Answer:

The program in C++ is as follows:

#include<iostream>

using namespace std;

void displayData(int height, int length, double Area){

   printf("Height: %d \n", height);

   printf("Length: %d \n", length);

printf("Area: %.2f \n", Area);

}

double trigArea(int height, int length){

double area = 0.5 * height * length;

   displayData(height,length,area);

   return area;

}

void getData(){

   int h,l;

   cin>>h>>l;

   trigArea(h,l);

}

int main(){

   getData();

   return 0;

}

Explanation:

See attachment for complete program where comments are used to explain the solution

Use the drop-down menus to answer questions about the options in the Window group. Which command allows a user to view presentations side by side? Which command allows a user to show one presentation overlapping another? Which command allows a user to jump from one presentation to another?

Answers

Answer:

Look at the attached file for the correct answer to  this question on edge:

Explanation:

The command allows a user to jump from one presentation to another Switch windows.

What is Switch windows?

Flip is similar to the Task view feature, although it operates somewhat differently. Click the Task view button in the taskbar's lower-left corner to launch Task view.

As an alternative, you can use your keyboard's Windows key and Tab. You can click on any open window to select it from a list of all your open windows.

It may be challenging to view the desktop if you have many windows open at once. When this occurs, you can minimize all currently open windows by clicking the taskbar's bottom-right corner. Simply click it once again to bring back the minimized windows.

Therefore, The command allows a user to jump from one presentation to another Switch windows.

To learn more about Windows, refer to the link:

https://brainly.com/question/13502522

#SPJ3

HURRY- I’ll give 15 points and brainliest answer!!
How do you insert text into a presentation??
By selecting text from the insert menu
By clicking in the task pane and entering text
By clicking in a placeholder and entering text
By drawing a text box clicking in it and entering text
(This answer is multiple select)

Answers

Answer:

the last one the drawing thingy:)))

For this lab you will write a class to create a user-defined type called Shapes to represent different shapes, their perimeters and their areas. The class should have three fields: shape, which is of type string, and perimeter and area of type double. The program will have to be able to calculate perimeters and areas for circles, triangles, squares and rectangles, which are the known shapes.
2.1 Constructors
Write these constructors:
1. Default constructor that sets the shape to "unknown" and the perimeter and area to 0
2. Constructor with one parameter, shape, that sets the shape, other fields are 0
2.2 Accessors & Mutators
Write the following member methods:
1. setShape()
Modifies the shape field
2. getShape()
Returns the shape field
3. getPerimeter()
Returns the perimeter field
4. getArea()
Returns the area field
Arithmetic Methods in Interface
Write the following member methods to perform arithmetic:
1. setPerimeter(Scanner scnr)
Depending on the shape, prompts the user for appropriate variables (ie width & height for a square, radius for a circle, etc.) and calculates the perimeter of the appropriate shape. The perimeter field should be updates with the new value. If the shape is unknown, then print to the screen that the user must first define a shape before a perimeter can be calculated and set the perimeter to 0.
2. setArea(Scanner scnr)
Depending on the shape, prompts the user for appropriate variables (ie width & height for a square, radius for a circle, etc.) and calculates the area of the appropriate shape. The area field should be updates with the new value. If the shape is unknown, then print to the screen that the user must first define a shape before an area can be calculated and set the area to 0.
2.3 Additional Methods
Create two additional methods of your choice. Be sure to clearly label both of these methods as your own.
2.4 Using another .java file called ShapesTest.java that tests that all of your methods work correctly

Answers

Answer:

========= Shape.java  ===========

//import the Scanner class

import java.util.Scanner;

public class Shape{

   //required fields

  private String shape;

   private double area;

   private double perimeter;

   //default constructor

  public Shape(){

       this.shape = "unknown";

       this.area = 0.0;

       this.perimeter = 0.0;

   }

   //constructor with one parameter

   public Shape(String shape){

       this.setShape(shape);

       this.area = 0.0;

       this.perimeter = 0.0;

   }

   //accessors and mutators

  public void setShape(String shape){

       this.shape = shape;

   }

  public String getShape(){

       return this.shape;

   }

   public double getPerimeter(){

       return this.perimeter;

   }

  public double getArea(){

       return this.area;

   }

  public void setPerimeter(Scanner scr){

       if(this.getShape().equals("circle")){

           System.out.println("Enter the radius of the circle");

           double radius = scr.nextDouble();

           this.perimeter = 2 * 3.142 * radius;

       }

       else if(this.getShape().equals("rectangle")){

           System.out.println("Enter the width");

           double width = scr.nextDouble();

           System.out.println("Enter the height");

           double height = scr.nextDouble();

           this.perimeter = 2 * (width + height);

       }

       else if(this.getShape().equals("square")){

           System.out.println("Enter the height or width");

           double height = scr.nextDouble();

           this.perimeter = 4 * height;

       }

       else if(this.getShape().equals("unknown")){

           System.out.println("You must define a shape first before calculating perimeter");

           this.perimeter = 0.0;

       }

       else {

           System.out.println("You must define a shape first before calculating perimeter");

           this.perimeter = 0.0;

       }

   }

   public void setArea(Scanner scr){

       if(this.getShape().equals("circle")){

           System.out.println("Enter the radius of the circle");

           double radius = scr.nextDouble();

           this.area = 3.142 * radius * radius;

       }

       else if(this.getShape().equals("rectangle")){

           System.out.println("Enter the width");

           double width = scr.nextDouble();

           System.out.println("Enter the height");

           double height = scr.nextDouble();

           this.area = width * height;

       }

       else if(this.getShape().equals("square")){

           System.out.println("Enter the height or width");

           double height = scr.nextDouble();

           this.area = height * height;

       }

       else if(this.getShape().equals("unknown")){

           System.out.println("You must define a shape first before calculating area");

           this.area = 0.0;

       }

       else {

           System.out.println("You must define a shape first before calculating area");

           this.area = 0.0;

       }

   }

   //Own methods

   //1. Method to show the properties of a shape

   public void showProperties(){

       System.out.println();

       System.out.println("The properties of the shape are");

       System.out.println("Shape : " + this.getShape());

       System.out.println("Perimeter : " + this.getPerimeter());

       System.out.println("Area : " + this.getArea());

   

   }

   //2. Method to find and show the difference between the area and perimeter of a shape

   public void getDifference(){

       double diff = this.getArea() - this.getPerimeter();

       System.out.println();

       System.out.println("The difference is " + diff);

   }

}

========= ShapeTest.java  ===========

import java.util.Scanner;

public class ShapeTest {

   public static void main(String [] args){

       Scanner scanner = new Scanner(System.in);

       // create an unknown shape

       Shape shape_unknown = new Shape();

       //get the shape

       System.out.println("The shape is " + shape_unknown.getShape());

       //set the area

       shape_unknown.setArea(scanner);

       //get the area

       System.out.println("The area is " + shape_unknown.getArea());

       //set the perimeter

       shape_unknown.setPerimeter(scanner);

       //get the perimeter

       System.out.println("The perimeter is " + shape_unknown.getPerimeter());

       // create another shape - circle

       Shape shape_circle = new Shape("circle");

       //set the area

       shape_circle.setArea(scanner);

       //get the area

       System.out.println("The area is " + shape_circle.getArea());

       //set the perimeter

       shape_circle.setPerimeter(scanner);

       //get the area

       System.out.println("The perimeter is " + shape_circle.getArea());

       //get the properties

       shape_circle.showProperties();

       //get the difference between area and perimeter

       shape_circle.getDifference();

   }

}

Sample output:

The shape is unknown

You must define a shape first before calculating area

The area is 0.0

You must define a shape first before calculating perimeter

The perimeter is 0.0

Enter the radius of the circle

>> 12

The area is 452.448

Enter the radius of the circle

>> 12

The perimeter is 452.448

The properties of the shape are

Shape : circle

Perimeter : 75.408

Area : 452.448

The difference is 377.03999999999996

Explanation:

The code above is written in Java. It contains comments explaining important parts of the code. Please go through the code for more explanations. For better formatting, the sample output together with the code files have also been attached to this response.

NAME SEARCH In the Chap07 folder of the Student Sample Programs, you will find the following files: GirlNames.txt—This file contains a list of the 200 most popular names given to girls born in the United States from 2000 through 2009. BoyNames.txt—This file contains a list of the 200 most popular names given to boys born in the United States from 2000 through 2009. Create an application that reads the contents of the two files into two separate arrays or Lists. The user should be able to enter a boy’s name, a girl’s name, or both, and the application should display messages indicating whether the names were among the most popular.

Answers

Answer:

Explanation:

I do not have the files listed in the question so I have made two test files with the same names. This code is written in Python, we are assuming that the names on each file are separated by newlines.

f1 = open("GirlNames.txt", 'r')

f1_names = f1.read()

f1_names_list = f1_names.split('\n')

f2 = open("BoyNames.txt", 'r')

f2_names = f2.read()

f2_names_list = f2_names.split('\n')

print(f1_names_list)

print(f2_names_list)

boy_or_girl = input("Would you like to enter a boy or girl name or both: ").lower()

if boy_or_girl == 'boy':

   name = input("Enter name: ")

   if name in f2_names_list:

       print("Yes " + name + " is in the list of most popular boy names.")

   else:

       print("No, it is not in the list")

elif boy_or_girl == 'girl':

   name = input("Enter name: ")

   if name in f1_names_list:

       print("Yes " + name + " is in the list of most popular girl names.")

   else:

       print("No, it is not in the list")

elif boy_or_girl == 'both':

   girlname = input("Enter Girl name: ")

   if girlname in f1_names_list:

       print("Yes " + girlname + " is in the list of most popular girl names.")

   else:

       print("No, it is not in the list")

   boyname = input("Enter name: ")

   if boyname in f2_names_list:

       print("Yes " + boyname + " is in the list of most popular girl names.")

   else:

       print("No, it is not in the list")

else:

   print("Wrong input.")

Other Questions
Virtual libraries Supporting Student,Purpose of this text? President Polk started the conflict bydeclaring warO ordering U.S. troops to invade the disputed areao order the navy to blockade MexicoKilling Mexico's leader Which was a positive effect of westward expansion for native americans? Jackie weeded the neighbors' gardens all summer. The 6 neighbors paid:$4.00 $6.00 $6.00 $5.00$ 8.00 7.00What was the mean amount paid? Plz help me its my last question giving brainliest Which of the following is a type of body language?A.Slowing down your speech to emphasize a pointB.Gesturing with hands to emphasize certain wordsC.Repeating important words more than onceD.Repeating words such as um The legislative branch enforces the law to make sure people follow them? True or False PLEASE HELP!!Closely examine the writers word choice in the excerpt from Passage B below. What tone--attitude do the writers words convey?Today, basic classroom subjects like writing, reading, mathematics, science, and history are being neglected by state education authorities. Making tougher requirements for teaching personal finance would be a waste of time and money. Read the passage from "The Salem (and Other) Witch Hunts, which is an informational text about witch hunts in the late 1600s.The sentencing of Bridget Bishop, the first victim of the witch trials, was typical of the Salem justice. Bishop was accused of not living "a Puritan lifestyle" because she wore black clothing. Her coat had been found to be oddly "cut or torn in two ways, and her behavior was regarded as "immoral. Thus convicted of witchcraft, she was tried on June 10, 1692, and executed by hanging the same day.Immediately following this execution, the court adjourned for 20 days and asked for advice from New England's most influential ministers "upon the state of things as they then stood. A mere five days later, they produced a voluble answer penned by Cotton Mather, the prolific pamphleteer of the period, assuring the court and the grand jury that they had done well.The prominent ministers "humbly recommend[ed]" more of the same: that is, "the speedy and vigorous prosecution of such as have rendered themselves obnoxious, according to the direction given in the laws of God, and the wholesome statutes of the English nation . . . More people were accused, arrested and examined, but historians believe that by September 1692 the hysteria had begun to abate and public opinion turned against the trials.Which text structure supports the idea that the sentencing was swift and the hysteria surrounding the witch hunts was relatively short-lived?sequencecomparison-contrastcause-effectproblem-solution Select the correct answer.Why does the author include this sentence in paragraph 3?"Late that night, we were awakened by a creaking and snorting and the flash of torches passing."To create an opportunity for the men to end their suffering in the heat andget on the two-wheeled cart and move faster towards their journey.B. To create an element of suspense because the men are asleep and are morevulnerable to attack.C.To create a sense of humanity in himself, by sharing his envy because hehasn't shown any emotion,D. To create a shift in the story, where the men in the camp seemingly have aglimmer of reprieve and find assistance for their travels ahead. if you think im attractive comment if not i dunno HELP I'm not good in scienceWhich process most likely caused or formed the sedimentary rock: chemical weathering, mechanical weathering (abrasion, exfoliation), erosion and/or deposition? Justify your answer. Helpp plzz will mark brainlrast The smaller the mass of an object, the _____ its inertia Describe the role of family in the socialization of villages and cities. 4) To drink something all at onceA) To down itB) Take a shotC) To out itD) To swallow it Imagine that a researcher correctly computes a correlation coefficient to quantify the relationship between two variables. In the data set that she works with, low scores on Variable X tend to be paired with low scores on Variable Y, and high scores on Variable X tend to be paired with high scores on Variable Y. Based on this data set, what type of correlation coefficient should the researcher expect to find Erik transformed the equation y = 2(x 2)2 + 5 from vertex form to standard form. His steps are shown below. Is Erik's work correct? If not, identify and correct his error.y = 2(x 2)2 + 5y = 2(x2 4x + 4) + 5y = 2x2 8x + 8 + 5y = 2x2 8x + 13answer choicesNo. The error is in the second line: the expanded form of (x 2)2 is x2 4.No. The error is in the third line: the product of 2 and x2 4x + 4 is 2x2 4x + 4.No. The error is in the fourth line: the sum of 8 and 5 is 12.Yes. Erik is correct in his transformation from vertex form to standard form. 8. Does the equation show a proportional relationship?y = x + 9O YesO No "Many villages have become quite empty. No one is left in the houses for the people are dead. And truly, many of these villages will now forever be emptyThis one by Henry Kright describes theGreat SchiomFall of RomeBlack PlagueSpaiching