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

The following code does not work as intended. It is meant to input two test grades and return the average in decimal format: int

test1 = scan.nextInt(); int test2 = scan.nextInt(); double average = (test1 + test2 )/2; System.out.println("Answer: " + average);
Computers and Technology
1 answer:
yuradex [85]3 years ago
6 0

Answer:

To return average in Decimal we will use float datatype instead of double.

Explanation:

int test1 = scan.nextInt();

int test2 = scan.nextInt();

float average = (test1 + test2 )/2;

System.out.println("Answer: " + average);

You might be interested in
What is causing the electricity prices to increase in South Africa?​
Pepsi [2]
The law of demand says that the higher the price of a good is, the less people will demand it. But South Africa , sales of electricity have been dropping, yet the utility wants consumers to even pay more for its good. The national utility, South Africa wants consumers to pay more for electricity.
4 0
2 years ago
Creating calendar events prevents individuals from being able to schedule a time to collaborate.
Yuliya22 [10]

Answer:

False because calender events help a person remeber when s/he has a event happening that day!

6 0
3 years ago
g Write a function called price_of_rocks. It has no parameters. In a while loop, get a rock type and a weight from the user. Kee
Scilla [17]

Answer:

<u>The pseudocode:</u>

FUNCTION price_of_rocks():

  SET total = 0

  while True:

      INPUT rock_type

      INPUT weight

      if rock_type is "Quartz crystals":

         SET total += weight * 23

      elif rock_type is "Garnets":

         SET total += weight * 160

      elif rock_type is "Meteorite":

         SET total += weight * 15.50

       

       INPUT choice

       if choice is "n":

           break

 

   RETURN total

END FUNCTION

<u>The code:</u>

def price_of_rocks():

   total = 0

   while True:

       rock_type = input("Enter rock type: ")

       weight = float(input("Enter weight: "))

       

       if rock_type == "Quartz crystals":

           total += weight * 23

       elif rock_type == "Garnets":

           total += weight * 160

       elif rock_type == "Meteorite":

           total += weight * 15.50

           

       choice = input("Continue? (y/n) ")

       if choice == "n":

           break

   

   return total

print(price_of_rocks())

Explanation:

Create a function named price_of_rocks that does not take any parameters

Initialize the total as 0

Create an indefinite while loop. Inside the loop:

Ask the user to enter the rock_type and weight

Check the rock_type. If it is "Quartz crystals", multiply weight by 23 and add it to the total (cumulative sum). If it is "Garnets", multiply weight by 160 and add it to the total (cumulative sum). If it is "Meteorite", multiply weight by 15.50 and add it to the total (cumulative sum).

Then, ask the user to continue or not. If s/he enters "n", stop the loop.

At the end of function return the total

In the main, call the price_of_rocks and print

4 0
3 years ago
Match the technology with the appropriate task.
Fiesta28 [93]

Answer:

the number order is

1

5

2

4

3

Explanation:

I am sure it is correct. Thanks :)

3 0
2 years ago
Email Communication has it own set of etiquette guidelines for users to follow if they want to be effective communicators. Which
Olin [163]
You answer is most likely D.
5 0
2 years ago
Other questions:
  • When an Ethernet frame arrives at a computer, the Ethernet layer must hand the packet that it contains to the next higher layer
    9·1 answer
  • To keep your emails concise and to the point
    13·1 answer
  • Which css property configures the capitalization of text?
    12·1 answer
  • An indicator is a comprehensive analysis of critical information
    8·1 answer
  • Why is it important to study in a quiet well lit area
    5·2 answers
  • Which disc store compacity for full lenght movie? dvd or cd
    14·1 answer
  • There are types of templates​
    5·1 answer
  • What type of platform is Twitter?
    10·2 answers
  • How does social network use message to entertain?
    14·1 answer
  • Where did the name "QWERTY" come from?​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!