Question

Creates MATLAB program that acts like an user-machine interface which will help the user to know...

Creates MATLAB program that acts like an user-machine interface which will help the user to know about any updates about COVID-19 only in the particular states in the USA including the areas affected and the number of registered positive cases along with number of deaths.

State = ["WASHINGTON", "CALIFORNIA", "VIRGINIA", "TEXAS", "MARYLAND", "COLORADO", "OKLAHOMA", "KANSAS", "LOUISIANA", "INDIANA", "PENNSYLVANIA", "NEW JERSEY", "NEW YORK", "MAINE", "NEW MEXICO", "ARIZONA"];

Cases = [1376, 1030, 105, 307, 107, 277, 46, 35, 392, 60, 206, 742, 5711, 52, 35, 45];

Deaths = [74, 18, 2, 5, 1, 4, 1, 1, 10, 2, 1, 9, 38, 0, 0, 0];

FOR EXAMPLE* WASHINGTON has 1376 cases of COVID-19 in which 74 deaths.**

****Should make use of the use given data set above.****

Write MATLAB code that operationalizes the algorithm. The code will need to use input, vectors, repetition (while loop), selection/decision structures (if-end, if-elseif, and/or if-else), and output in meaningful ways. Program should use at least one input statement in your MATLAB code. Input statement should not be used for the data set.

The program should ask the user to enter the name of the state and it should process the data about the cases and deaths (according to the data in vectors given). This program should make use of while loops and selection/decision structures too.

The program will also create an deaths/cases ratio which will determine if it's safe to travel to that particular state or not. It should print a message regarding it.

*FOR EXAMPLE**ARIZONA has 0 deaths, implying 0 deaths/cases ratio. The program should print a message something like, "It is safe in Arizona, but it is advisable to carry all the necessary protections.."

**The maximum threshold for death, case ratio can be any number chosen by YOU**..

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

In this problem, we need to write a matlab code that will act like a user-machine interface. The program should ask the user to enter the name of the state, and then the code will start to process the data about the cases and deaths. It should use while loops.
The program will also create a death/case ratio to determine if the state is safe to travel and based on that it prints a message.
The corresponding matlab code is shown below

clear all
clc

%% dataset for each state of USA
State = {'WASHINGTON'; 'CALIFORNIA'; 'VIRGINIA'; 'TEXAS'; 'MARYLAND'; 'COLORADO'; 'OKLAHOMA'; 'KANSAS'; 'LOUISIANA'; 'INDIANA'; 'PENNSYLVANIA'; 'NEW JERSEY'; 'NEW YORK'; 'MAINE'; 'NEW MEXICO'; 'ARIZONA'};
Cases = [1376, 1030, 105, 307, 107, 277, 46, 35, 392, 60, 206, 742, 5711, 52, 35, 45]';
Deaths = [74, 18, 2, 5, 1, 4, 1, 1, 10, 2, 1, 9, 38, 0, 0, 0]';

%% performing while loop
while(1)
  
    %% user input
    UserInput = input('insert the name of the state where you want to travel \n','s');
    count = 0; % check whether the inserted state is in the database
  
    for i = 1:length(State)
        val = strcmp(cell2mat(State(i)), UserInput); %% compare the string
      
        if(val == 1) %% if the inserted string is in the database
            count = 1;
            index = i;
            C_state = Cases(index); % obtain the no of cases;
            D_state = Deaths(index); % obtain the no of deaths;
          
            %% display the result
            disp('The inserted State is')
            disp(UserInput)
            disp('The number of cases in that state is')
            disp(C_state)
            disp('The number of deaths in that state is')
            disp(D_state)
          
            %% calculate death/case ratio
            r_state = D_state/C_state;
            if(r_state == 0) %% thresold limit chosen to be 0
                disp('The inserted state is safe, but it is advisable to carry all the necessary protections.."')
            else
                disp('It is advisable not to travel in this state')
            end
        end
    end
  
    if(count == 0)
        disp('inserted state is not in the database!!!')
    end
  
end

Add a comment
Know the answer?
Add Answer to:
Creates MATLAB program that acts like an user-machine interface which will help the user to know...
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
  • Matlab a) Write a MATLAB code that takes the grade letters from the user and provide him/her with the GPA for that seme...

    Matlab a) Write a MATLAB code that takes the grade letters from the user and provide him/her with the GPA for that semester Enter your grades (letters): AABBC (input) Your GPA is 3.2 output) b) Write a Matlab user defined function to that takes a letter grade and return a numeric grade as shown in the table below. Any other value should give an error message (Invalid Grade). You function name should be Letter2Grade Use the following information to calculate...

  • Write a program that keeps track of a speakers’ bureau. The program should use a structure...

    Write a program that keeps track of a speakers’ bureau. The program should use a structure to store the following data about a speaker: (this is in C++) Name Telephone Number Speaking Topic Fee Required The program should use a vector of structures. It should let the user enter data into the vector, change the contents of any element, and display all the data stored in the vector. The program should have a menu-driven user interface. Input Validation: When the...

  • Write a program which: - prompts the user for 2 numerical inputs - stores their two...

    Write a program which: - prompts the user for 2 numerical inputs - stores their two inputs in variables as floats - Use a while in loop to ask a user for a valid operation: (if the user's input operation isn't one of those listed above, instead print a message telling them so, and continue asking for the valid operation) - prompts the user for an arithmetic operation ( + - * / %) - stores the user's input as...

  • Java programming only Create a Java program that inputs a grade from the user. The grade input from the user will be an...

    Java programming only Create a Java program that inputs a grade from the user. The grade input from the user will be an integer. Once the input is stored, use an if-else-if block of code to determine the letter grade of the inputted integer grade. Do not use a bunch of if statements by themselves to solve this problem. You will print an error message for inputs greater than 100 and for inputs less than 0. Both errors must be...

  • In C++ ab 8 DESCRIPTION: Complete all four problems. 1. Write a program that will accept...

    In C++ ab 8 DESCRIPTION: Complete all four problems. 1. Write a program that will accept two numbers from the user. The program should then evaluate the following equation, using the data input: 2-3X2 - 4Y?. Assume the second number input is Y. Now the program should test Z to see if Z is a negative number or a positive number (assume zero is included as a positive number). The program should output the values of X, Y, and Z...

  • Write a program that uses a structure to store the following data about a customer account: Name Address City, sta...

    Write a program that uses a structure to store the following data about a customer account: Name Address City, state, and ZIP Telephone number Account Balance Date of last payment The program should use an vector of at least 20 structures. It should let the user enter data into the vector, change the contents of any element, and display all the data stored in the array. The program should have a menu-driven user interface. Input Validation: When the data for...

  • Write a Python program that keeps reading in names from the user, until the user enters...

    Write a Python program that keeps reading in names from the user, until the user enters 0. Once the user enters 0, you should print out all the information that was entered by the user. Use this case to test your program: Input: John Marcel Daisy Samantha Nelson Deborah 0 ================ Output: John Marcel Daisy 25 Samantha Nelson Deborah Hints: Create an array Names to hold the input names. Use the Names.append(x) function to add a new name to the...

  • I need this MATLAB question answered ASAP!!! thanks in advance! 10 Write a program which prompts...

    I need this MATLAB question answered ASAP!!! thanks in advance! 10 Write a program which prompts the user for data and returns the mean. The code should execute the following steps: 1) Prompts the user to enter the number of observations 2) Use a FOR-LOOP to get data from user. At each iteration, the user is asked for value of the i-th observation 3) At each iteration, print the mean of the sample up to and including the i-th observation...

  • With your partner, brainstorm a program that will ask the user for a number of digits...

    With your partner, brainstorm a program that will ask the user for a number of digits to be stored. The program should then create an array of that size and then prompt the user for numbers to fill each position in the array. When all of the positions are filled, display the contents of the array to the user. Create a new Project named FillArray and a new class in the default packaged named FillArray.java. You and your partner should...

  • Write a MATLAB program that will determine the condition of a nuclear reactor. The user will...

    Write a MATLAB program that will determine the condition of a nuclear reactor. The user will input the temperature and pressure values read from gages. The program will determine the state of the nuclear reactor and then output using fprintf the following statement: The Nuclear Reactor is categorized as: followed by the correct Category.   Other Requirements for the Program: If the readings put the condition in two different categories, the higher category should be selected. For example, a reactor with...

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