Matlab code for the problem
clc; clear; % Clearing the command window and workspace
% The given test examples
info = ['JUL 02 1998';
'AUG 05 2002';
'DEC 17 1920'];
names = ['Hannah';
'Daniel';
'Cedric'];
scoreString = birthdayParty(info,names) % Calling the function
% the function
function scoreString = birthdayParty(info,names)
scoreString = '';
[M,~] = size(names); % getting the nuber of persons
score = zeros(1,M); % Part 1 setting the scre to zero
for i = 1:M % lop for each person
Mth = info(i,1:3); % extracting the month from info
% Part 2 % checking the month and adding value to score
if (Mth=='JAN')|(Mth=='FEB')|(Mth=='MAR')|(Mth=='APR')|(Mth=='MAY')|(Mth=='JUN')
score(i) = score(i) + 3;
elseif (Mth=='JUL')|(Mth=='AUG')|(Mth=='SEP')|(Mth=='OCT')|(Mth=='NOV')|(Mth=='DEC')
score(i) = score(i) + 8;
end
Dt = str2num(info(i,5:6)); % extracting date from info
% Part 3 adding 2 points if the date is odd
if(mod(Dt,2) == 1)
score(i) = score(i) + 2;
end
Yr = str2num(info(i,8:11));% extracting the year from the info
% Part 4
if Yr<2000 % adding score 5 if the year is less than 2000
score(i) = score(i) + 5;
else % adding score 10 if the year is greater than or equal to 2000
score(i) = score(i) + 10;
end
end
[~,I] = max(score); % Checking the maximum score
% and creating the output string accordingly
scoreString = sprintf('%s has the coolest birthday with a score of %d!\n',names(I,:),score(I));
end
Screen Print of the code
Screen Print of the output
matlab 28 pts Question 8 Problem 4. Write the following function. Do NOT hard code using...
python Days of the Week Function Name: days_of_the_week() Parameters: list of birthdays ( list ), year (int ) Returns: list of names ( list ) Description: You and your friends all want to celebrate your birthdays together, but you don't want to stay up late on a school night. Write a function that takes in a list of tuples formatted as (day ( int ), month ( int ), name (string)), and a year ( int ). Use Python's calendar...
Objective: Learn how to -- read string from a file -- write multiple files Problem: Modify the Person class in Lab #4. It has four private data members firstNam (char[20]), day, month, year (all int); and two public member functions: setPerson(char *, int, int, int) and printInfo(). The function setPerson sets the first name and birthday in the order of day, month and year. The function printInfo prints first name and birthday. But it should print the date in the...
NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions Work with files Overview This lab will have you store the birthdays for a group of people. This program will store the information with the focus on the date of the month and not on the individual. The point of this program is to be able to see who has a birthday on a given day or to create a table of birthdays, in...
NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions Work with files Overview This lab will have you store the birthdays for a group of people. This program will store the information with the focus on the date of the month and not on the individual. The point of this program is to be able to see who has a birthday on a given day or to create a table of birthdays, in...
1. (10 pts) Write a function called hws_problem1 that accepts three input arguments: 1) a 3-column string matrix (say names), 2) a 4-column numeric matrix (say, numbers), and 3) a scalar threshold value (say, threshold). Note that the names matrix is the new string type that uses double quotes. The first two input arguments contain information about U.S. astronauts, where each corresponding row of the two matrices represents a single astronaut. The columns of the two matrices contain the following...
write a code on .C file Problem Write a C program to implement a banking application system. The program design must use a main and the below functions only. The program should use the below three text files that contain a set of lines. Sample data of these files are provided with the assessment. Note that you cannot use the library string.h to manipulate string variables. For the file operations and manipulations, you can use only the following functions: fopen(),...
Need C programming help. I've started to work on the program, however I struggle when using files and pointers. Any help is appreciated as I am having a hard time comleting this code. #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX_LINE 100 #define MAX_NAME 30 int countLinesInFile(FILE* fPtr); int findPlayerByName(char** names, char* target, int size); int findMVP(int* goals, int* assists, int size); void printPlayers(int* goals, int* assists, char** names, int size); void allocateMemory(int** goals, int** assists, char*** names, int size);...
// CSE240 Spring 2019 HW 7 & 8 // Write your name here // Write the compiler used: Visual studio or gcc // READ BEFORE YOU START: // You are given a partially completed program that creates a linked list of patient information. // The global linked list 'list' is a list of patients with each node being struct 'patientList'. // 'patientList' consists of struct 'patient' which has: patient name, room number, and a linked list of 'doctors'. // The...
In C++ Do not use a compiler like CodeBlocks or online. Trace the code by hand. Do not write "#include" and do not write whole "main()" function. Write only the minimal necessary code to accomplish the required task. Save your answer file with the name: "FinalA.txt" 1) (2 pts) Given this loop int cnt = 1; do { cnt += 3; } while (cnt < 25); cout << cnt; It runs ________ times ...
using matlab In Class Exercises 8-Arrays For the following exercises, assume an array is already populated, your job is to write a program that traverses the array. DO NOT HARD CODE the last index. In other words, you code for 1-4&6 should be able to handle the following 2 arrays: amp2 10 array1 [52, 63, 99, 71, 3.1] array2 - [99:-3: 45); For 5: wordArray1 wordArray2 ('number, 'arrays', 'indices', 'hello', finish' [number, 'different, 'finish? 1. Determine the sum of all...