Question

In java1. Monkey Business (10 points) A local zoo wants to keep track of how many pounds of food each of its three monkeys eats each

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program Code Screenshot :

Main.java import java.util.Scanner; 1 2 3 4 5 class Main { public static void main(String[] args) { Scanner obj = new Scanner

Sample Output :

Run: Main . C:\Program Files\Java\jdk-13\bin\java.exe 87 987 6 7 849 8 8 796 Average amount of food 7.4 Least amount of foo

Program Code to Copy

import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner obj = new Scanner(System.in);
        //Array to store food
        double food[][] = new double[3][5];
        double total = 0;

        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 5; j++) {
                //Read food
                food[i][j] = obj.nextDouble();
                while(food[i][j]<0){
                    System.out.print("Quantity can't be negative. Please re-enter : ");
                    food[i][j] = obj.nextDouble();
                }
            }
        }

        //Initialize min and max
        double max = food[0][0];
        double min = food[0][0];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 5; j++) {
                while(food[i][j]<0){
                    System.out.print("Quantity can't be negative. Please re-enter : ");
                    food[i][j] = obj.nextDouble();
                }
                //Find total
                total += food[i][j];
                //Find max and min
                max = Math.max(max, food[i][j]);
                min = Math.min(min, food[i][j]);
            }
        }
        double avg = total/15d;
        //Print results
        System.out.println("Average amount of food "+avg);
        System.out.println("Least amount of food "+min);
        System.out.println("Greatest amount of food "+max);
    }
}
Add a comment
Know the answer?
Add Answer to:
In java 1. Monkey Business (10 points) A local zoo wants to keep track of how...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ Monkey Business A local zoo wants to keep track of how many pounds of food...

    C++ Monkey Business A local zoo wants to keep track of how many pounds of food each of its three monkeys eats each day during a typical week. Write a program that stores this information in a two-dimensional 3 × 5 array, where each row represents a different monkey, and each column represents a different day of the week. The program should first have the user input the data for each monkey. Then, it should create a report that includes...

  • Pseudocode please Special Problem for Swap A local zoo wants to keep track of how many...

    Pseudocode please Special Problem for Swap A local zoo wants to keep track of how many pounds of food each of its three monkeys eats each day during a typical week. Write a program that stores this information in a two-dimensional 3 x 7 array, where each row represents a different monkey and each column represents a different day of the week. The monkeys are represented by integers 1, 2, and 3; the weekdays are "Sunday" "Monday" "Tuesday". "Wednesday. Thursday"....

  • In C++ Rewrite Modularity section to clarify functions should be separate. Assignment 6 - Monkey Food...

    In C++ Rewrite Modularity section to clarify functions should be separate. Assignment 6 - Monkey Food In the Gaddis textbook read Chapter 8 sections 8.1-8.9 before starting this assignment. This assignment is Programming Challenge 4 from Chapter 8 of the textbook. A local zoo wants to keep track of how many pounds of food each of its three monkeys eats each day during a typical week. Write a program that stores this information in a two-dimensional 3 x 7 arrray,...

  • What are the 8 errors in this C++ program below: /* CSE 100 Professor Feng Learn...

    What are the 8 errors in this C++ program below: /* CSE 100 Professor Feng Learn to read data from user and fill a two-dimensional array. Learn how to compute the sum of one row or one column in a 2D array Learn how to compute the sum, average of a 2D array */ #include<iostream> #include<cmath> #include<iomanip> using namespace std; double bananaMon=0; //Global Variables to be used in the program double bananaSat=0; double totalSum=0.0; //Global variable total sum double findGroupTotal();...

  • Write a program in java. You are tasked with writing an application that will keep track...

    Write a program in java. You are tasked with writing an application that will keep track of Insurance Policies. Create a Policy class called InsurancePolicies.java that will model an insurance policy for a single person. Use the following guidelines to create the Policy class: • An insurance policy has the following attributes: o Policy Number o Provider Name o Policyholder’s First Name o Policyholder’s Last Name o Policyholder’s Age o Policyholder’s Smoking Status (will be “smoker” or “non-smoker”) o Policyholder’s...

  • Looking for some help with this Java program I am totally lost on how to go about this. You have been approached by a local grocery store to write a program that will track the progress of their sale...

    Looking for some help with this Java program I am totally lost on how to go about this. You have been approached by a local grocery store to write a program that will track the progress of their sales people (SalesPerson.java) The information needed are: D Number integer Month 1 Sales Amount-Double Month 2 Sales Amount-Double Month 3 Sales Amount-Double Write a Java program that allows you to store the information of any salesperson up to 20 While the user...

  • Please write a Java program that ask the user how many beers he or she expects...

    Please write a Java program that ask the user how many beers he or she expects to consume each day, on average, as well as the average amount of money he or she spends on a single 12-ounce can of beer. Studies have shown that, on average, someone who consumes a single 12-ounce can of beer every day without compensating for the calorie intake through diet modifications or extra exercise, will gain approximately 15 pounds in one year. You can...

  • I am writing a Python program to serve as a fitness tracker. I would love some...

    I am writing a Python program to serve as a fitness tracker. I would love some input as to how you would code this. I've included what I want this program to accomplish, what I will keep track of, and below all of that I have posted the assignment guidelines. Any suggestions on how to make this better/ more efficient would be welcome! I'm thinking of making a weekly tracker that takes input per day, and outputs at the end...

  • Java Objective: The goal of this assignment is to practice 2-dimensional ragged arrays. Background: Within a...

    Java Objective: The goal of this assignment is to practice 2-dimensional ragged arrays. Background: Within a healthy, balanced diet, a grownup needs 2,250 calories a day You will write a program to track calorie intake of a person. Assignment: Calorie intake data from a person is provided in a text file named input.txt. There are arbitrary number of double values on each line, separated by spaces. The numbers represent the number of calories consumed for meals and/or snacks on a...

  • Answer using Java Part I: Feeding the Animals (3 points) Filename(s): PetShelter.java Alicia is responsible for...

    Answer using Java Part I: Feeding the Animals (3 points) Filename(s): PetShelter.java Alicia is responsible for buying a week's supply of food and medication for the dogs and cats at a local animal shelter. The food and medication for each dog costs twice as much as those for a cat. Each week the number of cats and dogs changes, as well as how much money she has available to spend on the animals. Write a program that asks the user...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT