![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
![Create Array of Random Dates
In this task you are required to write a function that will generate a column array (a variable called dates) containing random dates
N is an integer (whole number) entered by the user and will indicate to the function how many random dates the user requires
The dates array will be structured as follows:
• The array shall have two columns: column 1 will contain numbers indicating the day of each month (1-31) and column 2 will contain
numbers indicating the month (Jan-1, Feb-2, Mar-3 Dec-12).
• Each day must be randomly generated (using the randi function) taking into account the maximum number of days in each month (
Jan, Mar, May, Jul, Aug. Oct and Dec have 31 days. Apr. Jun. Sep and Nov have 30 days and Feb will have 28 days). You must use an
-eleif-else statement to decide this
We are assuming no les years (e. February can only have days between 1-28).
For example, the output from calling the function:
output dategen(3)
could be:
output =
23
14
11
6
Important note: Make sure you do not use the 'clear' or 'cle' keywords in your solution.
11
5
Function
function dates dategen (N)
Code to call your function
1 output dategen(3)
My Solutions>
Save C Reset
MATLAB Documentation
Reset](https://content.bartleby.com/qna-images/question/5e781105-97d2-4c44-bb9e-d30534019737/a63b4760-4d14-4ddc-8a50-5859dfa98e68/b94yd8_thumbnail.png)
Transcribed Image Text:Create Array of Random Dates
In this task you are required to write a function that will generate a column array (a variable called dates) containing random dates
N is an integer (whole number) entered by the user and will indicate to the function how many random dates the user requires
The dates array will be structured as follows:
• The array shall have two columns: column 1 will contain numbers indicating the day of each month (1-31) and column 2 will contain
numbers indicating the month (Jan-1, Feb-2, Mar-3 Dec-12).
• Each day must be randomly generated (using the randi function) taking into account the maximum number of days in each month (
Jan, Mar, May, Jul, Aug. Oct and Dec have 31 days. Apr. Jun. Sep and Nov have 30 days and Feb will have 28 days). You must use an
-eleif-else statement to decide this
We are assuming no les years (e. February can only have days between 1-28).
For example, the output from calling the function:
output dategen(3)
could be:
output =
23
14
11
6
Important note: Make sure you do not use the 'clear' or 'cle' keywords in your solution.
11
5
Function
function dates dategen (N)
Code to call your function
1 output dategen(3)
My Solutions>
Save C Reset
MATLAB Documentation
Reset
Expert Solution
![Check Mark](/static/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 3 steps with 1 images
![Blurred answer](/static/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- c++ If you pass a variable by ________________ to a function, the function will have access to the parameter’s original argument. Changes to the parameter are also made to the argument.arrow_forwardComplete the function ConvertToDecadesAnd Years to convert totalYears to decades and years. Return decades and years using the ElapsedDecades Years struct. Ex: 26 years is 2 decades and 6 years. 1 #include 2 3 typedef struct ElapsedDecadesYears_struct { int decadesVal;` 5 int yearsVal; 6) ElapsedDecadesYears; 7 8 Elapsed Decades Years ConvertToDecadesAndYears(int totalYears) { ElapsedDecades Years tempVal; /* Your code goes here */ 15 int main(void) { 8722878 25 26 } ElapsedDecadesYears elapsedYears; int totalYears; scanf("%d", &totalYears); elapsedYears = ConvertToDecadesAndYears (totalYears); printf("%d decades and %d years\n", elapsedYears.decadesVal, elapsedYears.yearsVal); return 0;arrow_forwardPlease complete the exercise as instructed and do not add global variables. Thank youarrow_forward
- Declare a function named contains_char. Its purpose is when given two strings, the first of any length, the second a single character, it will return True if the single character of the second string is found at any index of the first string, and return False otherwise.arrow_forwardprogram5_1.py Part 1Write a program that displays a table of ten distance equivalents in miles and kilometers. See Example output. You must generate the table by running a function inside a loop in main. Generate a random integer from 10 to 60, inclusive, in each loop cycle. Use this latter value as the miles argument to the function. Repeat: The function prints the table. Print the miles in a column 5 characters wide with 2 decimals and the kilometers in a column 13 characters wide with 5 decimals. Use the column formatting concepts at the end of Chapter 2, not tabs or other methods not in this course. Please include your psudocode to explain your code. Example output MILES KILOMETERS 52.00 83.68568 11.00 17.70274 40.00 64.37360 21.00 33.79614 14.00 22.53076 23.00 37.01482 48.00 77.24832 22.00 35.40548 15.00 24.14010 16.00 25.74944 program5_2.py Part 2Write another program that generates another table with the same columns and decimals…arrow_forwardC++ Create a function that will read the following .txt file contents and put them into an array: "apple", "avocado", "apricot","banana", "blackberry", "blueberry", "boysenberry","cherry", "cantaloupe", "cranberry", "coconut", "cucumber", "currant","date", "durian", "dragonfruit","elderberry",arrow_forward
- Complete the Funnyville High School registration program where user is prompted for her full name and the program generates email id and temporary password. Sample run: generate_EmailID: This function takes two arguments: the user’s first name and last name and creates and returns the email id as a string by using these rules: The email id is all lower case. email id is of the form “last.first@fhs.edu”. e.g. For "John Doe" it will be "doe.john@fhs.edu". See sample runs above. generate_Password: This function takes two arguments: the user’s first name and last name and generates and returns a temporary password as a string by using these rules. Assume that user's first and last names have at least 2 letters. The temporary password starts with the first 2 letters of the first name, made lower case. followed by a number which is the sum of the lengths of the first and last name (For example this number will be 7 for "John Doe" since length of "John" is 4 and length of "Doe" is…arrow_forwardthe code CREATE FUNCTION Calculate_Monthly_Payment( @mortage_amount BIGINT , @apr DECIMAL(18, 6) , @years INT)RETURNS DECIMAL(18, 6)ASBEGIN /* A = P (i + i (1+i) −1 n ) where: A = Monthly Payment Amount P = Principle (Initial) Mortgage Amount i = APR / 12 = Monthly Interest Rate n = years * 12 = Total Number of Payments */ -- Calculate monthly interest rate DECLARE @i DECIMAL(18, 6) SET @i = @apr / 12 DECLARE @n INTEGER SET @n = @years * 12 RETURN (@mortage_amount *@i * POWER(1+@i,@n)) / (POWER(1+@i, @n) - 1) END isn't working it shows that ERROR: syntax error at or near "@" LINE 3: @mortage_amount BIGINT ^ SQL state: 42601 Character: 48arrow_forwardINCHES_TO_CM = 2.54POUNDS_TO_KG = 0.453592def inches_to_cm( inches ):'''Function -- inches_to_cmConverts inches to centimeters and returns (answers) the resultingvalueParameters:inches (float) -- the original distance/height in inchesReturns a float value representing the original vaule convertedto centimeters'''return abs(inches * INCHES_TO_CM) # convert negative distance to positivedef cm_to_inches( centimeters ):'''Function -- cm_to_inchesConverts centimeters to inches and returns (answers) the resultingvalueParameters:centimeters (float) -- the original distance/height in centimetersReturns a float value representing the original vaule convertedto inches'''return abs(centimeters * (1 / INCHES_TO_CM))def pounds_to_kg( pounds ):'''Function -- pounds_to_kgConverts pounds to kilograms and returns (answers) the resultingvalueParameters:pounds (float) -- the original weight in poundsReturns a float value representing the original vaule convertedto kilograms'''return abs(pounds *…arrow_forward
- The prompt asks: Write a function that calculates the amount of money a person would earn over a period of years if his or her salary is one penny the first day, two pennies the second day, and continues to double each day. The program should ask the user for the number of years and call the function which will return the total money earned in dollars and cents, not pennies. Assume there are 365 days in a year. function totalEarned(years) { } var yearsWorked = parseInt(prompt('How many years will you work for pennies a day? ')); alert('Over a total of ' + yearsWorked + ', you will have earned $' + totalEarned(yearsWorked));arrow_forwardWhen a function accepts several arguments, how important is it what order those arguments are sent in?arrow_forwardThe program should allow the user to enter the age of the child and the number of days per week the child will be at the day care center. The program should output the appropriate weekly rate. The file provided for this lab contains all of the necessary variable declarations, except the two-dimensional array. You need to write the input statements and the code that initializes the two-dimensional array, determines the weekly rate, and prints the weekly rate. Comments in the code tell you where to write your statements. 1. Open the source code file named DayCare.cpp using Notepad or the text editor of your choice. 2. Declare and initialize the two-dimensional array. 3. Write the C++ statements that retrieve the age of the child and the number of days the child will be at the day care center. 4. Determine and print the weekly rate. 5. Save this source code file in a directory of your choice, and then make that directory your working directory. 6. Compile the source code…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
![Text book image](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
![Text book image](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
![Text book image](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
![Text book image](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
![Text book image](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
![Text book image](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education