You have been given two classes, a Main.java and a Coin.java. The coin class represents a coin. Any object made from it will have a 1) name, 2) weight and 3) value. As of now, the instance variables in Coin.java are all public, and the main function is calling these variables directly for the one coin made in it.

Required:
Your goal is to enforce information hiding principles in this tasl. Take Coin.java, make all instance variables private and create set/get functions for each instance variable. Then replace the direct references in main() to each instance variable with a call to an appropriate set or get function.

Answers

Answer 1

Answer:

Here is the Coin class:

public class Coin {  //class names

 private int value;  // private member variable of type int of class Coin to store the value

 private String coinName;  // private member variable of type String of class Coin to store the coint name

 private double weight;      //private member variable of type double of class Coin to store the weight

  public void setValue (int v) {  //mutator method to set the value field

    value = v;  }  

     

 public void setName(String n){  //mutator method to set coinName field

    coinName = n;}  

 public void setWeight (double w) {  //mutator method to set weight field

    weight = w;  }  

 public int getValue () {  //accessor method to get the value

   return value;  }  // returns the current value

 

 public String getName () {  //accessor method to get the coin name

   return coinName;  }  //returns the current coin name

   

 public double getWeight () {   //accessor method to get the weight

   return weight;  } } //returns the current weight

 

Explanation:

Here is the Main.java

public class Main{ //class name

public static void main(String[] args) { //start of main method

Coin penny = new Coin(); //creates object of Coin class called penny

penny.setName("Penny");  //calls setName method of Coin using object penny to set the coinName to Penny

penny.setValue(1); //calls setValue method of Coin using object penny to set the coin value to 1

penny.setWeight(0.003); //calls setWeight method of Coin using object penny to set the coin weight to 0.003

   System.out.println("Coin name: " + penny.getName()); // calls getName method of Coin using penny object to get the current coin name stored in coinName field    

   System.out.println("Coin value: " + penny.getValue()); // calls getValue method of Coin using penny object to get the coin value stored in value field    

   System.out.println("Coin weight: " +penny.getWeight()); }} // calls getWeight method of Coin using penny object to get the coin weight stored in weight field    

The value of coinName is set to Penny, that of value is set to 1 and that of weight is set to 0.003 using mutator method and then the accessor methods to access these values and prinln() to display these accessed values on output screen. Hence the output of the entire program is:

Coin name: Penny                                                                                                                                Coin value: 1                                                                                                                                   Coin weight: 0.003

The screenshot of the program along with its output is attached.

You Have Been Given Two Classes, A Main.java And A Coin.java. The Coin Class Represents A Coin. Any Object

Related Questions

You've been hired by Maple Marvels to write a C++ console application that displays information about the number of leaves that fell in September, October, and November. Prompt for and get from the user three integer leaf counts, one for each month. If any value is less than zero, print an error message and do nothing else. The condition to test for negative values may be done with one compound condition. If all values are at least zero, calculate the total leaf drop, the average leaf drop per month, and the months with the highest and lowest drop counts. The conditions to test for high and low values may each be done with two compound conditions. Use formatted output manipulators (setw, left/right) to print the following rows:________.
September leaf drop
October leaf drop
November leaf drop
Total leaf drop
Average leaf drop per month
Month with highest leaf drop
Month with lowest leaf drop
And two columns:
A left-justified label.
A right-justified value.
Define constants for the number of months and column widths. Format all real numbers to three decimal places. The output should look like this for invalid and valid input:
Welcome to Maple Marvels
------------------------
Enter the leaf drop for September: 40
Enter the leaf drop for October: -100
Enter the leaf drop for November: 24
Error: all leaf counts must be at least zero.
End of Maple Marvels
Welcome to Maple Marvels
------------------------
Enter the leaf drop for September: 155
Enter the leaf drop for October: 290
Enter the leaf drop for November: 64
September leaf drop: 155
October leaf drop: 290
November leaf drop: 64
Total drop: 509
Average drop: 169.667
Highest drop: October
Lowest drop: November
End of Maple Marvels

Answers

Answer:

#include <iostream>

#iclude <iomanip>

#include <algorithm>

using namespace std;

int main(){

int num1, num2, num3,  

int sum, maxDrop, minDrop = 0;

float avg;

string end = "\n";

cout << " Enter the leaf drop for September: ";

cin >> num1 >> endl = end;

cout << "Enter the leaf drop for October: ";

cin >> num2 >> endl = end;

cout << "Enter the leaf drop for November: ";

cin >> num3 >> endl = end;  

int numbers[3] = {num1, num2, num3} ;

string month[3] = { "September", "October", "November"}

for ( int i =0; i < 3; i++) {

 if (numbers[i] < 0) {

   cout << "Error: all leaf counts must be at least zero\n";

   cout << "End of Maple Marvels\n";

   cout << "Welcome to Maple Marvels";

   break;

 } else if (number[i] >= 0 ) {

     sum += number[i] ;  

   }

}

for (int i = 0; i < 3; i++){

 cout << month[i] << " leaf drop: " << numbers[i] << endl = end;

}

cout << "Total drop: " << sum << endl = end;  

cout << setprecision(3) << fixed;

cout << "Average drop: " << sum / 3<< endl = end;

maxDrop = max( num1, num2, num3);

minDrop = min(num1, num2, num3);

int n = sizeof(numbers)/sizeof(numbers[0]);

auto itr = find(number, number + n, maxDrop);

cout << "Highest drop: "<< month[ distance(numbers, itr) ] << endl = end;

auto itr1 = find(number, number + n, minDrop);

cout << "Lowest drop: " << month[ distance(numbers, itr1) ] << endl = end;

cout << "End of Maple Marvels";

Explanation:

The C++ source code above prompts for user input for three integer values of the leaf drop count through the September to November. The total drop, average, minimum and maximum leaf drop is calculated and printed out.

Seamus has too much text in one cell but wants all the information to be visible at once. What should he do? force the text to wrap force the text to spill-over truncate the text force the text to be inserted to next cell

Answers

Answer:

A: force the text to wrap

Explanation:

Just took the test and got it right!!! Hope this helps :D

Answer:

A) Force the text to wrap

Explanation:

Did it on ed2020

Jason works as a financial investment advisor. He collects financial data from clients, processes the data online to calculate the risks associated with future investment decisions, and offers his clients real-time information immediately. Which type of data processing is Jason following in the transaction processing system?

A.
online decision support system
B.
online transaction processing
C.
online office support processing
D.
online batch processing
E.
online executive processing

Answers

I believe the answer is A. because he has to listen to what the people tell him and he information he has to think about and make a choice on what to reply with.

I hope this helps and its correct please let me know if its wrong have a great day//night.

"Jean-luc Doumont notes that slide software is an effective presentation tool, especially when the speech goal is to:"

Answers

Hi, your question is incomplete. Here are the options:

A. persuade the audience.

B, encourage critical thinking.

C. increase discussion.

D. relay detailed information

Answer:

D. relay detailed information

Explanation:

Indeed, slide software (like MS Powerpoint) would be an effective presentation tool, especially when the speech goal is to relay detailed information.

For example, a graph showing the exponential growth in the number of smartphone users in the United States for the last 15 years would be effectively presented using a slide that shows this data because it will allow the audience to easily see the detailed information.

what is the provincial capital of lumbini province​

Answers

Answer:

hope it helps..

Explanation:

Butwal(recently changed again) , Rupendhai District

Consider a Stop-and-Wait protocol. Assume constant delays for all transmissions and the same delay for packets sent and ACKs sent. Assume no errors occur during transmission.
(a) Suppose that the timeout value is set to 1/2 of what is required to receive an acknowledgement, from the time a packet is sent. Give the complete sequence of frame exchanges when the sender has 3 frames to send to the receiver.
(b) Suppose that the timeout value is sent to 2 times the round trip time. Give the sequence of frame exchanges when 3 frames are sent but the first frame is lost.

Answers

Explanation:

question a) answer:

At the moment when it sends the package, then it has a waiting time for the acknowledgement from the receiver, however, the time will be split in two when the frameset size becomes two, meaning that two packages have been sent together, causing the receiver to acknowledge only one package.

question b) answer:

The timeout is equal to two times.

In cases when the frame size is 3, the frame will be lost since the timeout turns to be 2 times. Because the sender has to wait for the acknowledgement, therefore it will send other of the parcels.

Compare and contrast between flowcharts that involve:
-simple logic flow and

-simple logic flow with a two way branch

Answers

Answer:

The answer to this question is given below in the explanation section.

Explanation:

The solution to this question is given in the attached word file.  

The fraction 460/7 is closest to which of the following whole numbers?

Answers

I don’t see any of “the following numbers”

Write a program whose inputs are three integers, and whose output is the smallest of the three values. Use else-if selection and comparative operators such as '<=' or '>=' to evaluate the number that is the smallest value. If one or more values are the same and the lowest value your program should be able to report the lowest value correctly. Don't forget to first scanf in the users input.

Ex: If the input is: 7 15 3
the output is: 3

You should sketch out a simple flowchart to help you understand the conditions and the evaluations needed to determine what number is the correct answer. This type of tool can help determine flaws in a logical design.

Answers

Answer:

The Program written in C is as follows:

#include <stdio.h>

int main() {

   int num1, num2, num3, smallest;

   printf("Enter any three numbers: ");

   scanf("%d", &num1);    scanf("%d", &num2);    scanf("%d", &num3);

   if(num1 <= num2 && num1 <= num3) {

       smallest = num1;

   }

   else if(num2 <= num1 && num2 <= num3) {

       smallest = num2;

   }

   else {

       smallest = num3;

   }

   printf("Smallest: ");

   printf("%d", num3);

   return 0;

}

Explanation:

This line declares necessary variables

int num1, num2, num3, smallest;

This line prompts user for input of three numbers

   printf("Enter any three numbers: ");

This lines get input for the three numbers

   scanf("%d", &num1);    scanf("%d", &num2);    scanf("%d", &num3);

The following if/else statements determine the smallest of num1, num2 and num3 and assigns to variable smallest, afterwards

   if(num1 <= num2 && num1 <= num3) {

       smallest = num1;

   }

   else if(num2 <= num1 && num2 <= num3) {

       smallest = num2;

   }

   else {

       smallest = num3;

   }

The next two lines print the smallest value

   printf("Smallest: ");

   printf("%d", num3);

Jax needs to write a block of code that will organize a list of items alphabetically. Which function should he use? append() print() sort() order()

Answers

In python, the sort() function will alphabetically sort a list of strings

To write a block of code that will organize a list of items alphabetically  In python, the sort() function will alphabetically sort a list of strings.

What is python?

A high-level, all-purpose programming language is Python. Code readability is prioritized in its design philosophy, which makes heavy use of indentation. Python uses garbage collection and has dynamic typing. It supports a variety of paradigms for programming, including functional, object-oriented, and structured programming.

Python is a popular computer programming language used to create software and websites, automate processes, and analyze data. Python is a general-purpose language, which means it may be used to make many various types of applications and isn't tailored for any particular issues.

Sorting in Python simply means putting the data in a specific format or order. The order of the data pieces can be sorted either ascendingly or descendingly. Python programming contains certain built-in functions that allow you to sort the list's elements, just like C++ and Java.

Therefore, Thus option (C) is correct.

Learn more about python here:

https://brainly.com/question/18502436

#SPJ2

Jason works as a financial investment advisor. He collects financial data from clients, processes the data online to calculate the risks associated with future investment decisions, and offers his clients real-time information immediately. Which type of data processing is Jason following in the transaction processing system?

A.
online decision support system
B.
online transaction processing
C.
online office support processing
D.
online batch processing
E.
online executive processing

Answers

Answer:

The answer to this question is given below in the explanation section.

Explanation:

The correct answer to this question is online decision support system. Because the decision support systems process the data, evaluate and predict the decision, and helps the decision-makers,  and offer real time information immediately in making the decision in an organization. So the correct answer to this question is the decision supports system.

Why other options are not correct

Because the transaction processing system can only process the transaction and have not the capability to make the decision for the future. Office support processing system support office work, while the batch processing system process the task into the batch without user involvement.   however, online executive processing does not make decisions and offer timely information to decision-makers in an organization.

In Microsoft windows which of the following typically happens by default when I file is double clicked

Answers

Answer:

when a file is double clicked it opens so you can see the file.

Explanation:

Your job is to write a basic blurring algorithm for a video driver. The algorithm will do the following: it will go through all pixels on the screen and for each pixel, compute the average intensity value (in red, green and blue separately) of the pixel and its 8 neighbors. (At the edges of the screen, there are fewer neighbors for each pixel.) Let's say the number of pixels on the screen is n. Then what is the order of the number of arithmetic operations (additions and divisions) required?
a. The number is order of n 4 .
b. The number is order of n2.
c. The number is order of n
d. The number is order of n3.

Answers

I’m pretty sure answer is B let me know if I’m wrong

What are two examples of items in Outlook?

a task and a calendar entry
an e-mail message and an e-mail address
an e-mail address and a button
a button and a tool bar

Answers

Answer:

a task and a calendar entry

Explanation:

ITS RIGHT

Answer:

its A) a task and a calendar entry

Explanation:

correct on e2020

Which of the following is NOT a period of the Middle Ages?
Early Middle Ages
O Late Middle Ages
O High Middle Ages
O New Middle Ages
allowing is NOT an artifact of the Information Age?

Answers

High middle ages is the answer

The one that is not a period of the Middle Ages is the High Middle Ages. The correct option is c.

What are different ages?

The Middle Ages, which roughly correspond to the years 500 to 1400–1500 BCE, is the term used to describe this time of European history. The phrase was initially used by academics in the 15th century to refer to the time frame between their own era and the dissolution of the Western Roman Empire.

The period between the fall of Imperial Rome and the start of Early Modern Europe is referred to as the “Middle Ages” for this reason. The reason the Middle Ages are known as the Dark Ages is that life was hard and brief in Europe, and contrasted with the orderliness of classical antiquity.

The time period in European history from roughly 500 AD to 1500 AD. This time period's early years are commonly referred to as the Dark Ages.

Therefore, the correct option is c, High Middle Ages.

To learn more about the middle ages, refer to the link:

https://brainly.com/question/26586178

#SPJ6

Write a Python code to ask a user to enter students' information including name,
last name and student ID number. The program should continue prompting the
user to enter information until the user enters zero. Then the program enters
search mode. In this mode, the user can enter a student ID number to retrieve
the corresponding student's information. If the user enters zero, the program
stops. (Hint: consider using list of lists)​

Answers

database = ([[]])

while True:

   first_name = input("Enter the student's first name: ")

   if first_name == "0":

       while True:

           search = input("Enter a student ID number to find a specific student: ")

           if [] in database:

               database.pop(0)

           if search == "0":

               exit()

           k = 0

           for w in database:

               for i in database:

                   if i[2] == search:

                       print("ID number: {} yields student: {} {}".format(i[2], i[0], i[1]))

                       search = 0

   last_name = input("Enter the student's last name: ")

   id_number = input("Enter the student's ID number: ")

   database.append([first_name, last_name, id_number])

I hope this helps!

Read the following code:


x = 1

while(x < 26)

print(x)

x = x + 1


There is an error in the while loop. What should be fixed?


1. Add a colon to the end of the statement

2. Begin the statement with the keyword count

3. Change the parentheses around the test condition to quotation marks

4. Use quotation marks around the relational operator

Answers

This is python code.

In python, you are supposed to put a colon at the end of while loops. This code does not have a colon after the while loop, therefore, you need to add a colon to the end of the statement.

The error to be fixed in the while loop is to add a colon at the end of the while statements.

x = 1

while (x<26)

     print(x)

     x = x + 1

This is the right code;

x = 1

while(x < 26):

   print(x)

   x = x + 1

The actual code , the while statement is missing a colon at the end of it.

The code is written in python. In python while or for loops statements always ends with a colon.

In the error code, there was no colon at the end of the while loop.

The right codes which I have written will print the value 1 to 25.

learn more on python loop here: https://brainly.com/question/19129298?referrer=searchResults

Using Phyton

Write a program with the following functions.

function 1: Accepts 2 strings as arguments. returns true if the second string is a part of the first string.

Answers

def something(string1, string2):

return True if string2 in string1 else False

This would be the most concise way of writing this function.

write a program that calculates the total grade for N classroom exerices as a perfentage. the user should input the value for N followed by each of the N scores and totals.

Answers

Answer:

earned = 0

total = 0

exercises = int(input("Enter the number of exercises: "))

for i in range(exercises):

   score = int(input("Enter score" + str(i+1) + ": "))

   total_score = int(input("Enter total score for exercise " + str(i+1) + ": "))

   

   earned += score

   total += total_score

print("The total is %" + str(earned/total * 100))

Explanation:

*The code is in Python.

Set the earned and total as 0

Ask the user to enter the number of exercises

Create a for loop that iterates number of exercises times. For each exercise;

Ask the user to enter the score earned and total score of that exercise

Add the score to the earned (cumulative sum)

Add the total_score to the total (cumulative sum)

When the loop is done, calculate the percentage, divide earned by the total and multiply the result by 100, and print it

sum_even Write a program that reads an integer 0 < n < 2^32, returns the sum of all digits in n that are divisible by 2. For example, if n = 341238 the output would be 14, because it is the sum of 4 + 2 + 8. Hint: a signed int may not be enough.

Answers

Answer:

Written in Python

n = int(input("Num: "))

sum_even = 0

if n > 0 and n < 2**32:

     strn = str(n)

     for i in range(0,len(strn)):

           if int(strn[i])%2 == 0:

                 sum_even = sum_even+ int(strn[i])

print(sum_even)

Explanation:

This line prompt user for input

n = int(input("Num: "))

This line initializes sum_even to 0

sum_even = 0

This line checks for valid input

if n > 0 and n < 2**32:

This line converts input to string

     strn = str(n)

This line iterates through each digit of the input

     for i in range(0,len(strn)):

This if condition checks for even number

           if int(strn[i])%2 == 0:

This adds the even numbers

                 sum_even = sum_even+ int(strn[i])

This prints the sum of all even number in the user input

print(sum_even)

What is his resolution amount

Answers

I think it’s 92 I mean yh

21. Duplicating a layer merges all of the layers and discards anything that is
not visible. True or False
True
False

Answers

the answer is false. Because it just makes a copy, including all parts of the program.
The answer is false

Plz answer me will mark as brainliest ​

Answers

Answer:

True

Operating System

Booting

the language is Java! please help

Answers

public class Drive {

   int miles;

   int gas;

   String carType;

   public String getGas(){

       return Integer.toBinaryString(gas);

   }

   public Drive(String driveCarType){

       carType = driveCarType;

   }

   public static void main(String [] args){

       System.out.println("Hello World!");

   }

   

}

I'm pretty new to Java myself, but I think this is what you wanted. I hope this helps!

B1:B4 is a search table or a lookup value

Answers

Answer:

lookup value

Explanation:

Walter The Dog is hot
(This was a waste of 37 points lol)

Answers

Answer:

no

Explanation:

mabey yes

Lol the dog looks funny

What is the maximum number of VLANs that can be configured on a switch supporting the 802.1Q protocol? Why?

Answers

Answer:

4096 VLANs

Explanation:

A VLAN (virtual LAN) is a group of devices on one or more LAN connected to each other without physical connections. VLANs help reduce collisions.

An 802.1Q Ethernet frame header has VLAN ID of 12 bit VLAN field. Hence the maximum number of possible VLAN ID is 4096 (2¹²).  This means that a switch supporting the 802.1Q protocol can have a maximum of 4096 VLANs

A lot of VLANs ID are supported by a switch. The maximum number of VLANs that can be configured on a switch supporting the 802.1Q protocol is 4,094 VLANS.

All the VLAN needs an ID that is given by the VID field as stated in the IEEE 802.1Q specification. The VID field is known to be of  12 bits giving a total of 4,096 combinations.

But that of 0x000 and 0xFFF are set apart. This therefore makes or leaves it as 4,094 possible VLANS limits. Under IEEE 802.1Q, the maximum number of VLANs that is found on an Ethernet network is 4,094.

Learn more about VLANs from

https://brainly.com/question/25867685

A Windows user is locked out of her computer, and you must log into the local administrator account HelpdeskAdmin. Which would you use in the username field?

Answers

Answer: .\HelpdeskAdmin

Explanation:

If you wanted to log in as the local administrator then for the Username put a dot (.) and a backslash (\) in front of the Admin username.

The dot(.) will ensure that Windows knows that you are logging into a local computer as the administrator and so will grant you access. The relevant username therefore is, ''.\HelpdeskAdmin''.

I will use  .\HelpdeskAdmin as the username field.

What is a username field?

The username-field is known to be a kind of command that is said to specifies the value for the name that shows the characteristics in the login form and it is one that identifies the username field.

Note that the use of the .\HelpdeskAdmin as the username field is the right thing to do as the dot(.) will make sure that the Windows knows that the user is logging into a computer as the administrator.

Learn more about  local administrator from

https://brainly.com/question/14364696

Write a program that reads in 10 numbers from the user and stores them in a 1D array of size 10. Then, write BubbleSort to sort that array – continuously pushing the largest elements to the right side

Answers

Answer:

The solution is provided in the explanation section.

Detailed explanation is provided using comments within the code

Explanation:

import java.util.*;

public class Main {

//The Bubble sort method

public static void bb_Sort(int[] arr) {  

   int n = 10; //Length of array  

   int temp = 0; // create a temporal variable  

   for(int i=0; i < n; i++){  

         for(int j=1; j < (n-i); j++){  

           if(arr[j-1] > arr[j]){  

               // The bubble sort algorithm swaps elements  

               temp = arr[j-1];  

               arr[j-1] = arr[j];  

               arr[j] = temp;  

             }  

         }            

         }  

        }

 public static void main(String[] args) {

   //declaring the array of integers

   int [] array = new int[10];

   //Prompt user to add elements into the array

   Scanner in = new Scanner(System.in);

   //Use for loop to receive all 10 elements

   for(int i = 0; i<array.length; i++){

     System.out.println("Enter the next array Element");

     array[i] = in.nextInt();

   }

   //Print the array elements before bubble sort

   System.out.println("The Array before bubble sort");

   System.out.println(Arrays.toString(array));

   //Call bubble sort method

   bb_Sort(array);  

               

   System.out.println("Array After Bubble Sort");  

   System.out.println(Arrays.toString(array));

 }

}


What is the Intranet?

Answers

Answer:

a local or restricted communications network, especially a private network created using World Wide Web software.

Explanation:

the intranet is in private Network based on internet standards but only available within a business or other organization.

Other Questions
Slope point formpassing through (4,-7) with x intercept = -4 Who is able to type a minimum of 95 words every 2 minutes? Please Help!! Lets work on an old skill you ve already learned!Determine the following for the set of data13, 18, 13, 14, 13, 16, 14, 21, 13MeanMedianModeRange How does the author use rhetoric to advance the purpose of the text PLEASE HELP!!!!!! I HAVE TO TURN THIS IN SOON!!!!HELP ME FILL IN THE BLANKSOceanic crust is ___________ dense than continental crust, thus it goes underneath the continental crust forming a ________________. What did House's sister name the dog? The Belmont principle of beneficence requires that: Question 3(Multiple Choice Worth 1 points)What subject pronoun would you use when talking about Marie and Anne? I threw out some toys and I thought my student had outgrown.My student might feel: who is the governor of arizona and how taxes been used in phoenix? Which sentence contains a pronoun shift?Morgan gave his new business card to Antonio and me.If one eats sensibly, he or she can expect to feel better.If a runner wants to win, they should practice frequently.When employees park in the garage, they must pay, too. EMERGENCY! Please give me the correct answer! Pls help!!! will give brainly!!!!pls wright this sentence Spanish:There are plates, forks, and napkins on the lunch table.Use the verb hay Explain how you would dilute a 1 mol/dm solution to one-tenth of its originalconcentration. Using what you have learned about food in chile write 5 sentences about Chilean food and food from your country. Are there any similarities or differences? Please be clear and use the correct grammar. Thanks! What aspect does line weight represent? A. angle of a line B. color of a line C. length of a line D. thickness of a line A person invests 1000 dollars in a bank. The bank pays 6% interest compoundedmonthly. To the nearest tenth of a year, how long must the personleave the moneyin the bank until it reaches 3300 dollars? How do you think the Red Death entered the Princes abbey that was sealed in deep seclusion from the rest of the world? The average of 4,-8,6,14,-3 is keep the sign of the number with the largest absolute value