Question

Please write a code that will look like this. You CANNOT use ArrayLists or any type of List to store objects, Breaks, or continue statemets throughout the entire project. PLEASE only use basic Arrays Correctly use the “Prime the Read” method for inputting data before a sentinel loop. Note: You may not use any break or continue statements in your program to earn these points.

like- (Items in green/underline are the user inputs. Your program should not print these items) Example Output (No patient data) Welcome to the Flu Tracker Type of the name of the Influenza Type (x to exit) Summary information There were: 0 cases of Flu to summarize Example Output (With patient data Welcome to the Flu Tracker Type of the name of the Influenza Type (x to exit) What is the age of the patient? 15 Next Patient Type of the name of the Influenza Type (x to exit) What is the age of the patient? 87 Next Patient Type of the name of the Influenza Type (x to exit) H1N1 What is the age of the patient? Next Patient Type of the name of the Influenza Type (x to exit) What is the age of the patient? 37 Next Patient Type of the name of the Influenza Type (x to exit) Summary information Type: Influenza-AAge: 15 Type: Influenza-B Age: 87 Type: H1N1 Type: Influenza-AAge: 37 There were: 4 cases of Influenza with an average age of 35

0 0
Add a comment Improve this question Transcribed image text
Answer #1
import java.util.Scanner;

public class Influenza {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int capacity = 1000;
        String[] fluList = new String[capacity];
        int[] ageList = new int[capacity];
        String flu;
        int age;
        int size = 0;
        System.out.println("Welcome to the Flu Tracker.");
        System.out.println("Type of the name of the Influenza Type (x to exit)");
        flu = in.next();
        while (!flu.equalsIgnoreCase("x")) {
            System.out.println("What is the age of the patient?");
            age = in.nextInt();
            fluList[size] = flu;
            ageList[size++] = age;
            System.out.println("Next Patient");
            System.out.println("Type of the name of the Influenza Type (x to exit)");
            flu = in.next();
        }
        System.out.println("Summary information");
        if(size == 0) {
            System.out.println("There were: 0 cases of Flu to summarize");
        } else {
            int avg = 0;
            for(int i = 0; i < size; ++i) {
                System.out.println("Type: " + fluList[i] + " Age: " + ageList[i]);
                avg += ageList[i];
            }
            System.out.println("There were: " + size + " cases of Influenza with an average age of " + (avg/size));
        }
    }

}
Add a comment
Know the answer?
Add Answer to:
Please write a code that will look like this. You CANNOT use ArrayLists or any type...
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
  • Write a C# code for a Sales Calculator: Note: You cannot use the foreach loop in any part of this...

    Write a C# code for a Sales Calculator: Note: You cannot use the foreach loop in any part of this program! sales.txt file: 1189.55, 1207.00, 1348.27, 1456.88, 1198.34, 1128.55, 1172.37, 1498.55, 1163.29 The application should have controls described as follows: • A button that reads Get Sales. If the user clicks this button, the application should call a method named ProcesSalesFile. ProcessSalesFile Method: accepts no arguments and does not return anything The ProcessSalesFile Method will do the following: o Open...

  • write in java code. oop. i dont have its written code. i have its output in...

    write in java code. oop. i dont have its written code. i have its output in the thrid picture and how the inheritance works with the second picture. just need it in full written code and uni class will be. jus need you to write the whole code for me as its an extra question which i need for my preparation of my exam. add as you but it must be correct and similar to the question Inheritance Do the...

  • Write a C# code for a Sales Calculator: Note: You cannot use the foreach loop in...

    Write a C# code for a Sales Calculator: Note: You cannot use the foreach loop in any part of this program! sales.txt file: 1189.55, 1207.00, 1348.27, 1456.88, 1198.34, 1128.55, 1172.37, 1498.55, 1163.29 The application should have controls described as follows: • A button that reads Get Sales. If the user clicks this button, the application should call a method named ProcesSalesFile. ProcessSalesFile Method: accepts no arguments and does not return anything The ProcessSalesFile Method will do the following: o Open...

  • Program Description: A Java program is to be created to produce Morse code. The Morse code...

    Program Description: A Java program is to be created to produce Morse code. The Morse code assigns a series of dots and dashes to each letter of the alphabet, each digit, and a few special characters (such as period, comma, colon, and semicolon). In sound-oriented systems, the dot represents a short sound and the dash represents a long sound. Separation between words is indicated by a space, or, quite simply, the absence of a dot or dash. In a sound-oriented...

  • Python please help! Thanks you Write a code to get an unlimited number of grades from...

    Python please help! Thanks you Write a code to get an unlimited number of grades from the user (the user can press enter to finish the grades input, or use a sentinel, for example-1), and then calculate the GPA of all the grades and displays the GPA To do this you might need some help. Try to follow the following process (and check your progress by printing different values to make sure they are as they supposed to be): 1-...

  • Write a program that demonstrates use of programmer - defined data structures. Please provide code! Thank...

    Write a program that demonstrates use of programmer - defined data structures. Please provide code! Thank you. Here are the temps given: January 47 36 February 51 37 March 57 39 April 62 43 May 69 48 June 73 52 July 81 56 August 83 57 September 81 52 October 64 46 November 52 41 December 45 35 Janual line Iranin Note: This program is similar to another recently assigned program, except that it uses struct and an array of...

  • Use python write Thank you so much! pets.txt dog alyson 5.5 cat chester 1.5 cat felice...

    Use python write Thank you so much! pets.txt dog alyson 5.5 cat chester 1.5 cat felice 16 dog jesse 14 cat merlin 5 cat percy 12 cat puppet 18 to_transfer.txt cat merlin 5 cat percy 12 intake.txt bird joe 3 cat sylvester 4.5 the website is https://www2.cs.arizona.edu/classes/cs110/spring17/homework.shtml Welcome to animal shelter management software version 1.0 Type one of the following options adopt a pet adopt intake add more animals to the shelter list. display all adoptable pets quit exit the...

  • Objectives This is one of three major programming projects this semester. You should NOT collaborate on...

    Objectives This is one of three major programming projects this semester. You should NOT collaborate on this project. While you may ask for assistance in debugging, this project should be ENTIRELY your own work. Objectives include: . Use local variables. • Use arithmetic expressions. • Use Scanner to input values. • Use a class constant. • Use of nested branches. • Use for loxops. • Use of methods. • Use of arrays. Hand-in Requirements All projects and laboratories will be...

  • Please use C programming to write the code to solve the following problem. Also, please use the i...

    Please use C programming to write the code to solve the following problem. Also, please use the instructions, functions, syntax and any other required part of the problem. Thanks in advance. Use these functions below especially: void inputStringFromUser(char *prompt, char *s, int arraySize); void songNameDuplicate(char *songName); void songNameFound(char *songName); void songNameNotFound(char *songName); void songNameDeleted(char *songName); void artistFound(char *artist); void artistNotFound(char *artist); void printMusicLibraryEmpty(void); void printMusicLibraryTitle(void); const int MAX_LENGTH = 1024; You will write a program that maintains information about your...

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