Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Solve all problems in a single script file in Matlab. Each problem should utiliz

ID: 2293559 • Letter: S

Question

Solve all problems in a single script file in Matlab. Each problem should utilize conditional statements (if-statement or switch-case Use conditional statements to determine a student's cost of tuition next semester. Ask the user to enter the number of credit hours they plan to take. Assuming the student is non-resident, the cost per credit hour is $930. However, the cost is capped at 12 credit hours. (So if they have more than 12 credit hours, their tuition is still $930 * 12.) Display the sentence "It will cost $XXXX in tuition to take XX credit hours." 1. Ask the user to enter a value for variable, x. Use conditional statements to determine the value of y based upon the user's input. 2. You decide to play a game where you choose 2 cards at random from a deck of cards. You win the game if both of the 2 cards you pulled were "face" cards (King, Queen, and Jack). Use either randi or randperm to simulate the 2 cards that you pull. Use a conditional statement to display the message "You won" if both cards were face cards or the message "You lost" if they were not both face cards. (A deck of cards can be represented with the numbers 1-52. With 4 of each type of face card within a deck, there are a total of 12 face cards. You should represent the face cards with the range of numbers 37-48 or with 5-16.) 3.

Explanation / Answer

clear all;
clc;

%% Question 1:

No_hours = input('Enter the Number of Credit Hours: ');
CostPerCreditHour = 930;     % In dollers

if No_hours <= 12
    cost = No_hours * CostPerCreditHour;
elseif No_hours > 12
    cost = 12 * CostPerCreditHour;
end

fprintf('It will cost $%d in tution to take %d credit hours ',cost,No_hours)

%% Question 2:

x = input('Enter a value for varaible x: ');

if x <1
    y = x+7;
elseif x>=1 && x <4
    y = exp(x)+1;
elseif x>=4
    y = (x^2)-5;
end

fprintf('The Vlaue of Y: %d ',y)

%% Question 3:

y = input('Press 1 to choose two cards randomly: ');

if y==1
    Card1 = randi(52);
    Card2 = randi(52);
  
    fprintf('Card1 is %d ',Card1)
    fprintf('Card2 is %d ',Card2)
  
    if ((Card1>5 && Card1<16) || (Card1>37 && Card1<48)) && ((Card2>5 && Card2<16) || (Card2>37 && Card2<48))
        fprintf('You Won ');
    else
        fprintf('You lost ');
    end
else
    fprintf('Try Again ');
end

   

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote