1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
mixer [17]
4 years ago
6

Write in Java please

Computers and Technology
1 answer:
Mariulka [41]4 years ago
8 0

Answer: Provided in the section below

Explanation:

Using C# Code:

using System;

class Environment{

//temperature

private double temp;

//sets initial value of temp to 100 Fahrenheits

public Environment(){

temp=100;

}

//sets initial value to given temp

public Environment(double t) {

this.temp = t;

}

//returns temp

public double getTemp(){

return temp;

}

//calculates temp at given frequency

public void calcTemperature(double frequency){

temp=(frequency+40)/4.0;

}

}

class Cricket{

private Random r=new Random();

//frequency of birds

protected double frequency;

//sets frequency to a random value between 0-100

public Cricket(){

 

frequency=r.NextDouble()*100;

}

//sets frequency to a given frequency

public Cricket(double f) {

frequency = f;

}

//returns the frequency

public double getFrequency() {

return frequency;

}

//randomize the frequency

public virtual void randomFrequency() {

frequency = r.NextDouble()*100;

}

}

class ClemsonCricket: Cricket{

//sets the frequency to 80% of the parent's

public ClemsonCricket(): base(){

frequency=frequency*0.8;

}

//sets frequency to a given frequency

public ClemsonCricket(double f): base(f){}

//randomize frequency and sets it to 80% of the parent's

public override void randomFrequency(){

base.randomFrequency();

frequency=frequency*0.8;

}

}

public class testCrickets {

static void Main(){

Environment env=new Environment();

Console.WriteLine("Initial Temp: "+env.getTemp());

Cricket cricket=new Cricket();

env.calcTemperature(cricket.getFrequency());

Console.WriteLine(String.Format("Temp before changing Frequency: {0:0.00}",env.getTemp()));

cricket.randomFrequency();

env.calcTemperature(cricket.getFrequency());

Console.WriteLine(String.Format("\nTemp after changing Freqency: {0:0.00}",env.getTemp()));

Console.WriteLine("\nClemson Cricket: ");

ClemsonCricket clemsonCricket=new ClemsonCricket();

env.calcTemperature(clemsonCricket.getFrequency());

Console.WriteLine(String.Format("Temp before changing Frequency: {0:0.00}",env.getTemp()));

clemsonCricket.randomFrequency();

env.calcTemperature(clemsonCricket.getFrequency());

Console.WriteLine(String.Format("\nTemp after changing Freqency: {0:0.00}" ,env.getTemp()));

Console.WriteLine("\nPolymorphism Clemson Cricket: ");

Cricket Ccricket=new ClemsonCricket();

env.calcTemperature(Ccricket.getFrequency());

Console.WriteLine(String.Format("Temp before changing Frequency: {0:0.00}",env.getTemp()));

Ccricket.randomFrequency();

env.calcTemperature(Ccricket.getFrequency());

Console.WriteLine(String.Format("\nTemp after changing Freqency: {0:0.00}",env.getTemp()));

}

}

cheers i hope this helped !!

You might be interested in
How many fields can be sorted when sorting data in Word tables? up to 3 fields 1 field at a time up to 4 fields 2 fields at a ti
ValentinkaMS [17]

Answer:

up to 3 fields

Explanation:

You can sort using up to 3 fields at a time within a Ms Word table, as you can see in the image I join.  For each criteria column, you can chose to sort in ascending or descending order.

It's a bit surprising to see such capability in a word processing document.  You'd expect that in Ms Excel, which is a spreadsheet.

8 0
3 years ago
Read 2 more answers
When do you need to use a fully qualified url in a hyperlink?
Rudiy27
When you're linking to another web site.
7 0
3 years ago
The set Canvas.PaintColor to block sets the paint color for the _____ .
amid [387]

The set Canvas.PaintColor to block is a code that sets the paint color for the: D. canvas.

<h3>What is a canvas?</h3>

In Computer technology and graphics design, a canvas can be defined as a container that is literally used to hold various drawing elements in a graphics design software such as:

  • Lines
  • Shapes
  • Texts
  • Frames

In conclusion, the set Canvas.PaintColor to block is a code that is typically used to set the paint color for the canvas in a graphic design software.

Read more on graphic design here: brainly.com/question/25299426

#SPJ1

7 0
2 years ago
A telephone repair technician uses a meter to measure voltage on a phone line. This meter is an example of _____.
frozen [14]
It is an example of hardware.
3 0
3 years ago
Read 2 more answers
PLEASE HELP!!<br> Would you ever try and get famous off of social media? Why or why not?
Alexxandr [17]

Answer:

Yes because u could gain a lot of money from it

Explanation:

With more money you have, the more you can give to charity, and the more you can relax

3 0
3 years ago
Read 2 more answers
Other questions:
  • Perform online research and learn about the elements of a presentation program interface not discussed in the lesson. Write a sh
    9·1 answer
  • How to see if your computer has bluetooth?
    6·1 answer
  • Design and implement a java program (name it CheckPoint) that prompts the user to enter the x-coordinate and y-coordinate of a p
    6·1 answer
  • Why is it important to save a print copy of electronic sources
    5·1 answer
  • When an application contains an array and you want to use every element of the array in some task, it is common to perform loops
    14·1 answer
  • Give two separate print statements: one will print your name, the other will print your major. Ensure that both will print on th
    15·1 answer
  • ____ is a website that checks a submitted paper and then determines how much of the paper is unoriginal.
    12·1 answer
  • What will be displayed after the following statements execute? int funny = 7, serious = 15; funny = serious 2; if (funny != 1) f
    7·2 answers
  • A proposal is also known as a
    14·2 answers
  • 9. These particular machines can be decentralized.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!