Concept explainers
Function Implementation with Data Abstraction in C
1. Create a new file and SAVE as MATHV1.H
Define and Implement the following functions:
int sum(int x, int y);
- returns the computed sum of two numbers x and y
int diff(int x, int y);
- returns the computed difference of two numbers x and y.
Make sure that the larger number is deducted
by the smaller number to avoid a negative answer
long int prod(int x, int y);
- returns the computed product of two number x and y
float quot(int x, int y);
- returns the computed quotient of two numbers x and y.
Make sure that the larger number is always the numerator
and divided by the smaller number to avoid division
by zero error.
int mod(int x, int y);
- returns the computed remainder of two numbers x and y using
the modulo operator %
2. Create another new file and save as MYTOOLS.H
void center(int row, char str[]);
/*centers text across the screen
-calculate here for the center col using
the formula col=(80-strlen(str))/2;
-then use gotoxy(col,row) to print the value in string
str*/
void outString(int col,int row,char str[]);
/*outputs the string str at the specified col and row numbers.*/
void drawSBox(int x1,int y1, int x2, int y2);
/* draws a single-line box */
void drawDBox(int x1,int y1, int x2, int y2);
/* draws a double-line box */
note: you may place here the definition of your function
void menu();
/* to display this menu layout:
PROGRAMMING 2
FUNCTION IMPLEMENTATION
w/ DATA ABSTARACTION
=====================================
~~~~~ BASIC MATH OPERATIONS ~~~~~
MODULO [%]
DIVIDE [ / ]
MULTIPLY [ * ]
ADD [ +]
SUBTRACT [ - ]
Enter math operator[%/*+-]:
=======================================
3. Define the above functions declared in both MATHV1.H and MYTOOLS.H. Save them as
MATHV1.C and MYTOOLS.C respectively.
4. Create another new file and save it as FUNCTIONS.C
Include the files "MYTOOLS.H" and "MATHV1.H"
Requirements/Specifications:
-write a function main() to use all functions defined in MATHV1.H and MYTOOLS.H
-invoke the menu layout above w/ double-line box
-prompt the user to input and select a math operator
-the inputted math operator that are valid [% or / or * or + or - only]. If it's invalid, prompt
the user a message that it's invalid and ask him /her to input again
-If the math operator entered by the user is valid, draw a small double-line box and
prompt the user to input two numbers, like this:
_____________________________
Enter 1st number:
Enter 2nd number:
Result is :
_____________________________
Press 1 to continue or 0 to exit...
- Repeat the entire process while user response is
1 (for continue), program exits when user
replies 0 (means to exit)
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images
- Python only** define the following function: 1. This function must add a task to a checklist, setting its initial value to False. It will accept two parameters: the checklist object to add to, and the task name to add. In addition to adding the task, it must return the (now modified) checklist object that it was given. There is one issue, however: a task cannot be added to a checklist if the name requested is already being used by another task in that checklist. In that case, this function must print a specific message and must return None Define addTask with 2 parameters Use def to define addTask with 2 parameters Use a return statement Within the definition of addTask with 2 parameters, use return _ in at least one place. Do not use any kind of loop Within the definition of addTask with 2 parameters, do not use any kind of loop.arrow_forwardC++ Dynamic Array Project Part 2arrow_forwardMULTIPLE FUNCTIONS AND RECURSIVE FUNCTIONS HANDS-ON use #include<stdio.h>arrow_forward
- # dates and times with lubridateinstall.packages("nycflights13") library(tidyverse)library(lubridate)library(nycflights13) Qustion: Create a function called date_quarter that accepts any vector of dates as its input and then returns the corresponding quarter for each date Examples: “2019-01-01” should return “Q1” “2011-05-23” should return “Q2” “1978-09-30” should return “Q3” Etc. Use the flight's data set from the nycflights13 package to test your function by creating a new column called quarter using mutate()arrow_forwardneed help in C++ Problem: You are asked to create a program for storing the catalog of movies at a DVD store using functions, files, and user-defined structures. The program should let the user read the movie through the file, add, remove, and output movies to the file. For this assignment, you must store the information about the movies in the catalog using a single vector. The vector's data type is a user-defined structure that you must define on functions.h following these rules: Identifier for the user-define structure: movie. Member variables of the structure "movie": name (string), year (int), and genre (string). Note: you must use the identifiers presented before when defining the user-defined structure. Your solution will NOT pass the unit test cases if you do not follow the instructions presented above. The main function is provided (you need to modify the code of the main function to call the user-defined functions described below). The following user-defined functions are…arrow_forwardGame of Hunt in C++ language Create the 'Game of Hunt'. The computer ‘hides’ the treasure at a random location in a 10x10 matrix. The user guesses the location by entering a row and column values. The game ends when the user locates the treasure or the treasure value is less than or equal to zero. Guesses in the wrong location will provide clues such as a compass direction or number of squares horizontally or vertically to the treasure. Using the random number generator, display one of the following in the board where the player made their guess: U# Treasure is up ‘#’ on the vertical axis (where # represents an integer number). D# Treasure is down ‘#’ on the vertical axis (where # represents an integer number) || Treasure is in this row, not up or down from the guess location. -> Treasure is to the right. <- Treasure is to the left. -- Treasure is in the same column, not left or right. +$ Adds $50 to treasure and no $50 turn loss. -$ Subtracts…arrow_forward
- struct employee{int ID;char name[30];int age;float salary;}; (A) Using the given structure, Help me with a C program that asks for ten employees’ name, ID, age and salary from the user. Then, it writes the data in a file named out.txt (B) For the same structure, read the contents of the file out.txt and print the name of the highest salaried employee and youngest employee names name in the outputscreen.arrow_forwardProgramming Language: C++ 4. Select the two correct statements about stub functions: Select one or more: a. stubs are used to test the functionality of a program b. stubs must return a value c. stubs are programs that test if a called function returns the correct result d. stubs are simpler than the functions they replacearrow_forwardUsing C++ Language Write a function call with arguments tensPlace, onesPlace, and userInt. Be sure to pass the first two arguments as pointers. Sample output for the given program: tensPlace = 4, onesPlace = 1 Code: #include <stdio.h> void SplitIntoTensOnes(int* tensDigit, int* onesDigit, int DecVal){ *tensDigit = (DecVal / 10) % 10; *onesDigit = DecVal % 10;} int main(void) { int tensPlace; int onesPlace; int userInt; scanf("%d", &userInt); /* Your solution goes here */ printf("tensPlace = %d, onesPlace = %d\n", tensPlace, onesPlace); return 0;}arrow_forward
- 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