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]
3 years ago
6

Write in Java please

Computers and Technology
1 answer:
Mariulka [41]3 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
Your school has been declared a school of technology
Angelina_Jolie [31]
I don't really understand the meaning of the question. Can you reply and i'll try to help...
7 0
3 years ago
Which of the following is true about operating system.
zalisa [80]

Answer:

google kis kam ka hai us se puch lo

7 0
3 years ago
7.4.4: Length of User's Name
Natalija [7]

Answer:

user_name = input("input user name: ")
print(len(user_name))

Explanation:

input - input function in python

len - length of value

print - print data

6 0
2 years ago
How do you get stickman worriers
ira [324]
You go online and find the answer
8 0
3 years ago
A bag of biscuit can hold 22 biscuit, and a container can hold 70 bags of biscuit. Write a program that prompts the user to ente
Marta_Voda [28]
The answer is left over bags that make turtles sick
5 0
3 years ago
Read 2 more answers
Other questions:
  • Due to the internal style sheets of some browsers, your website may look different to someone who is using firefox as opposed to
    11·1 answer
  • Which of the following statements is true?
    14·1 answer
  • You've been asked to find the largest number in a range of numbers. Which of the following could you use to find the largest num
    8·1 answer
  • Footnotes and endnotes can be used to explain information in more detail, add opinions or comments, or to cite sources in the do
    7·1 answer
  • How we know that how many domain exist in window server 2012?
    14·1 answer
  • Need help please. this effect my technology
    15·1 answer
  • What is an Operating System ??
    7·1 answer
  • Describe five examples of civil engineering projects.
    6·1 answer
  • Please helpppppppppppppp
    11·1 answer
  • Implement a simplified version of a crypto broker platform. Initially, there is an array of users, with each user depositing onl
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!