Case Study 1: The following fragment of code in Figure 1 show the function to calculating the total price of soft drink orders. The soft drink is sold in boxes of 12 bottles and there are available in three flavour: falvour A (RM60), B(RM80) and C(RM100). int calcPrice (int qttyA, int qttyB, int qttyC, double price){ int discount = 0; if (qttyA== 2) discount = 5; else if (qttyA== 1 && qttyB: discount = 8; else if (qttyC == 3) else discount = 10; discount = 2; == 1) endif price = ((qttyA * 60) + (qttyB* 80)+ (qttyC* 100))* (100-discount)/100; return price;
Q: . Multicore CPUs facilitate multithreading. What ismultithreading?
A: Cpu allows multi tasking means two or more persons working on the same program is known as multi…
Q: Question: The Caesar cipher is a type of substitution cipher in which each alphabet in the plaintext…
A: Algorithm of the code: 1. Start 2. Take the key and the plaintext as input. 3. Initialize an array…
Q: Proposition Show that the marking algorithms LRU and FWF are.
A: Intruduction: a special online algorithm family for the paging problem called marking algorithms.…
Q: .Which storage medium would you use in each ofthe following situations: (1) airline…
A: Storage:- Storage is the process of keeping and maintaining data and information over time. It is…
Q: Let A1, A2, and A3 be attributes in a relation R. If both of these functional dependencies hold: A1…
A: The functional dependency A1->A3 holds due to the Transitive Rule of functional dependencies.…
Q: Contrast learning in a controlled setting with that in an unsupervised one.
A: In this question we will discuss on controlled learning and unsupervised learning Let's discuss
Q: 2. Consider the following function that counts the number of words in a string: void words (char…
A: The algorithm of the code is given below:- 1. Prompt the user to enter a string of up to 100…
Q: Question 11 Mah Source for a piece of Python code, between 20 to 50 lines (excluding comments),…
A: Source for a piece of Python code, between 20 to 50 lines (excluding comments), that…
Q: Difference between tail recursion and non tail recursion in tabular form with example.
A: Introduction: There is no other operation to perform after executing the recursive function itself…
Q: Answer the questions What does f(x) return? What values of x and y are used in the computation and…
A: Given, The code snippet: var x=5; function f(y) {return x+y ;} f(x); In the given code snippet,…
Q: What is a programming language? What is a database?
A: A programming language is a set of instructions that a computer can understand and execute to…
Q: In the context of neural networks, comparing supervised and unsupervised learning is an intriguing…
A: A labelled dataset is used as an answer key in a supervised learning model to train the algorithm…
Q: Contrasting supervised learning vs unsupervised learning within the context of neural networks is an…
A: In a supervised learning model, the algorithm is trained on a labelled data set, which serves as a…
Q: Write an assembly language program that corresponds to the following C program: int num; int main ()…
A: Answer: Here is an example of an x86 assembly language program that corresponds to the given C…
Q: 1.Perform penetration and vulnerability testing on partners with which you share your data…
A: Penetration testing and vulnerability testing: Penetration testing (pen-testing) is a security…
Q: BOOLEAN ALGEBRA Simplify the following expressions: (a) AB′C′ + A′B′C′ + A′BC′ + A′B′C (b) ABC +…
A: Boolean expression are simplified to reduce the number of gates used for building the logic circuit.…
Q: PART 1 Simplify the Boolean expressions below as much as you can (i.e., the minimum number of…
A: “Since you have posted multiple questions, we will provide the solution only to the first question…
Q: this exercise, assume that the user will correctly enter ID numbers and zip codes, but force each…
A: I have completed the code below: It creates objects of the Customer class and writes each object to…
Q: Hack 83: Use ++x Instead of x++ Because It's Faster The Problem: You need to increment a variable in…
A: We use Use the prefix increment (++x) instead of the postfix (x++) because it's faster.
Q: Question 2: DFAs For this question take >= {a,b} (a) Make a DFA (state-diagram), that accepts all…
A: Introduction DFA: A Deterministic Finite Automaton (DFA) is a type of computational machine used for…
Q: Run Levels and Editing Files Why are run levels used for Linux services? Discuss the importance of…
A: Since you have asked multiple questions, we will solve the first question for you. If you want any…
Q: In an SQL Injection attack, which occur? Group of answer choices Commands can be used to learn about…
A: SQL Injection attack:- SQL Injection is a type of attack where malicious code is inserted into a SQL…
Q: If you were going to develop a new mobileapplication for the Android, what are the varioussoftware…
A: Introduction : Google created the Android mobile operating system, which is based on the Linux…
Q: ALGORITHM 1 A Procedure for Computing the Transitive Closure. procedure transitive closure (MR:…
A: - We have to give the transitive closure of the relations using the algorithm. - I am using C++…
Q: Activity 2: Animation using Thread & GUI Develop the following GUI App Start Stop When Start button…
A: The code above creates a GUI app with a JFrame, two JButtons, and a JLabel. When the "Start" button…
Q: Write a python script that reads the file studentNames.txt which contains the names of students.…
A: CODE in Python: # Open the file in read modewith open("studentNames.txt", "r") as file: # Print…
Q: Is it true that neural networks process information in a sequential fashion? Explain.
A: GIVEN: Is it accurate to say that neural networks handle data sequentially? Explain. SOLUTION: In…
Q: rite an assembly language program that corresponds to the following C program: int num; int main ()…
A: Here is a possible assembly language program that corresponds to the given C program using the Pep/9…
Q: To appreciate how they operate, we must first know what artificial neural networks are
A: The term Neural recognize from the name of the nervous system's basic unit called neurons and the…
Q: cluding downvote so far as well incorrectly. Create two different forms of the INSERT command to…
A: Here for it note, we can only solve three subparts in one question. There are two types of…
Q: Give an NFA for the finite language Lf = { cat, dog, bird}. The procedure that you follow when…
A: Answer: To construct an NFA for the finite language L= { cat, dog, bird }, we can do the following:…
Q: Construct a truth table for the following: (x + y′)(x′ + z′)(y′ + z′)
A: Introduction Truth table: A truth table is indeed a tabular representation of each potential output…
Q: Answer the following questions on floating-point representation: a) Convert AD510010 16 to an IEEE…
A: (a) The given number is AD510010 which is equal to 10101101010100010000000000010000 in binary.…
Q: 10.13 LAB: Course information (derived classes) Given main(), define a Course base class with…
A: Algorithm: START Declare class Course and class OfferedCourse. Declare private variables…
Q: Determine whether these sequences of vertices are paths in this directed graph. b a) a, b, c, e b)…
A: “Since you have posted a question with multiple sub parts, we will provide the solution only to the…
Q: Write a shell script to display arguments to script. Enter any three input arguments to script and…
A: HI THEREI AM ADDING ANSWER BELOWPLEASE GO THROUGH IT THANK YOU
Q: (C#)Assume inputFile references a StreamReader object that is associated with a file that is already…
A: A) while (!inputFile.EndOfStream) { } If we want to read all the items which are located in a file,…
Q: Explain in mathematical terms the process of supervised learning in neural networks and the results…
A: Introduction: In deep learning techniques like deep reinforcement learning, artificial neural…
Q: Canada, uses the following formula with different constant values, temperatures in degrees Celsius…
A: Algorithm: Step 1: Start the program.Step 2: Take the temperature and wind velocity from the…
Q: QUESTION 2 Which of the following is NOT secondary storage device? random access memory solid state…
A: Introduction : A secondary device is a computing device that is used in addition to a primary…
Q: The command pattern and strategy patterns are widely used patterns for encapsulating a behavior or…
A: The Command and Strategy patterns can be used to encapsulate behaviors or algorithms, but each…
Q: 18. Determine whether there is a path in the directed graph in Exercise 16 beginning at the first…
A: Given graph contains, Set of vertices= {a, b, c, d, e} Unweighted directional edges are present…
Q: Ivan purchased a prepaid phone card for $20.00. Calls cost 5 cents a minute using this card. The…
A: Given prepaid phone card for $20.00. Calls cost 5 cents a minute using this card C(x)=20.00-0.05x…
Q: Write a Java program to accomplish each of the following tasks : (a) Add 10 to integer variable x.…
A: public class Main{ public static void main(String[] args) { int x=0; x=x+10; // Task 1…
Q: To finalize the degree centrality, let us take a look at the undirected graph, but now based on…
A: The code executes proc network to compute the degree centrality for the undirected graph based on…
Q: problem that lends itself to a dynamic programming solution is finding the longest common substring…
A: Algorithm of the code: //Initialize1. Set a 2D matrix with a row and column size equal to the…
Q: How to read data from client in servlet?
A: Introduction A servlet is a Java application that runs on the server and processes requests from a…
Q: 23.Comment on the following statement: the usefullife of a PC is about two years, therefore, it is…
A: computer lifespan is a key concern for consumers. However, most computers will survive five to eight…
Q: Exploring and Visualizing The Data Exploring your data using different types of visualizations is…
A: 1 # create histogram2 plt.hist(df['W'], bins=10)34 # add x-axis label5 plt.xlabel('Wins')67 # add…
Q: Let us define the custom tribonacci sequence as follows. To = A T₁ = B T₂ = C Ti = Ti-3 + Ti-2 +…
A: In this question we have to write a program for the Custom Tribonacci Sequence as per the given…
Draw the control flow graph of the code based on the image given
Step by step
Solved in 2 steps with 1 images
- Write a function numRolls that simulates the following dice game: a player repeatedly rolls a pair ofdice until the second time that doubles is rolled. The function then returns the total number of rollsmade. For example, suppose the player rolls the following pairs: (3,2), (3,3), (1,5), (5,5). The game thenstops because the player has rolled doubles twice, (3,3) and (5,5). The function returns 4, the totalnumber of rolls made: Use python6...Consider the definition of the function main. int main() { double rate, hours, amount; . . . } Each of the functions described must have the appropriate parameters to access these variables. Write the following definitions: a. Write the definition of the function getHoursRate that prompts the user to input the hours worked and rate per hour to initialize the variables hours and rate of the function main. b. Write the definition of the value-returning function payCheck that calculates and returns the amount to be paid to an employee based on the hours worked and rate per hour. The hours worked and rate per hour are stored in the variables hours and rate, respectively, of the function main. The formula for calculating the amount to be paid is as follows: For the first 40 hours, the rate is the given rate; for hours over 40, the rate is 1.5 times the given rate. c. Write the definition of the function printCheck that prints the hours worked, rate per hour, and the salary. d. Write the…Q. Please solve this C++ program and show all the steps. (kindly do not use any advanced coding or coding info from any other program. Don't copy from other sources too) a) Add a new function convMonth to the class Date that returns the month in letters (e.g., January, February, etc.). b)Add a function that prints the date using the following format: Month dd, yyyy . Example, January 21, 2023 c) Test the new functions of the class Date by creating dynamically (i.e., using pointers) two objects of the class Date and invoking the new member functions on both objects. Deliverables: date.h, date.cpp, testdate.cpp. (any description or thought process of this coding problem will be really useful, particularly in part c) please let me know if there's any way I could contact you for further assistance,( please!) Thank you !
- Hi, OCaml programming 1. Create a type slidingTile, consisting of a char matrix and two integers xand y. The integers x and y are the coordinates of an empty tile. 2. Create a function val slide : slidingTile -> int -> int -> slidingTile = <fun> that given a slidingTile and two integers, that represent a location in thematrix, it slides the tile from the specified location to the empty tile, thenreturns the altered slidingTile. If provided location is not adjacent to theempty tile, or out of bounds, then return the slidingTile unaltered. 3. Create a function val print_tile : slidingTile -> unit = <fun> that prints a slidingTile on screen with the corresponding characters fromthe matrix. However, print an empty space where the empty tile is instead.1. Write a function which takes one parameter int num, and prints out a countdown timer with minutes and seconds separated by a colon (:). It should print out one line for each second elapsed and then pause one second before printing out the next line. A few things to note: - You can assume that calling the function usleep(1000000) makes the program pause for one second - It should count down from num minutes:zero seconds to zero minutes:zero seconds - Your function must have the following signature: void timer(int num) You do not need to demonstrate calling this function from main(). You don't need to format the output nicely; the below is acceptable output for calling this function when minutes is 10: 10:0 9:59 9:58 … 9:1 9:0 8:59 8:58 … 0:2 0:1 0:0ASSIGNMENT Consider the following function. What is the purpose of the function f? Please do explain and describe in details all possible answers for this function given below.int f(int n) {if ((a >= b) && (c < b)) return b; else if (a >= b) return f(a, c, b); else return f(b, a, c);} To find the maximum number between a, b, and c. To find the middle number between a, b, and c. To find the minimum number between a, b, and c. None of the other statements. Suppose the letters a,b,c,d,e,f have probabilities of 1/2, 1/4, 1/8, 1/16, 1/32, 1/32 respectively. Which of the following is the Huffman code for the letter a,b,c,d,e,f? Please show how is the Huffman tree, so that you can determine one of the options below. 0, 10, 110, 1110, 11110, 11111 11, 10, 01, 001, 0001, 0000 11, 10, 011, 010, 001, 000 110, 100, 010, 000, 001, 111 An adjacency matrix of a graph is given below: matrix at photoFirst, draw the graph defined by that adjacency matrix, and label the…
- Consider the definition of the function main. int main() { double rate, hours, amount; . . . } Each of the functions described must have the appropriate parameters to access these variables. Write the following definitions: a. Write the definition of the function getHoursRate that prompts the user to input the hours worked and rate per hour to initialize the variables hours and rate of the function main. b. Write the definition of the value-returning function payCheck that calculates and returns the amount to be paid to an employee based on the hours worked and rate per hour. The hours worked and rate per hour are stored in the variables hours and rate, respectively, of the function main. The formula for calculating the amount to be paid is as follows: For the first 40 hours, the rate is the given rate; for hours over 40, the rate is 1.5 times the given rate. c. Write the definition of the function printCheck that prints the hours worked, rate per hour, and the…def rectangle_overlap(rect1_bl_x,rect1_bl_y, rect1_tr_x,rect1_tr_y, rect2_bl_x,rect2_bl_y, rect2_tr_x,rect2_tr_y): """ (int,int,int,int,int,int,int,int) -> str Function determines whether two rectangles overlap. When rectangles overlap, the function checks for the following scenarios 1. The two rectangles share the same coordinates 2. The first rectangle is contained within the second 3. The second rectangle is contained within the first 4. The rectangles have overlapping area, but neither is completely contained within the other Function inputs represent x and y coordinates of bottom left and top right corners of rectangles (see lab document) The function return one of the following strings corresponding to the scenario "no overlap" "identical coordinates" "rectangle 1 is contained within rectangle 2" "rectangle…(Fibonacci) The Fibonacci series0, 1, 1, 2, 3, 5, 8, 13, 21, …begins with the terms 0 and 1 and has the property that each succeeding term is the sum of the twopreceding terms. a) Write a nonrecursive function fibonacci(n) that calculates the nth Fibonaccinumber. Use unsigned int for the function’s parameter and unsigned long long int for its returntype. b) Determine the largest Fibonacci number that can be printed on your system.
- Consider the following function definition: void too2(int a[ ], int howMany) { for (int index = 0; index < howMany; index++) a[index] = 2; } Which of the following are acceptable function calls? int myArray[29]; too2(myArray, 29); too2(myArray, 10); too2(myArray, 55); "Hey too2. Please, come over here." int yourArray[100]; too2(yourArray, 100); too2(myArray[3], 29);C++ PLEASE WRITE FULL FUNCTION DEFINITION for THE FUNCTION IN PART B Given the Class Definition for ClockType discussed extensively in class, write what would have to be added to the IMPLEMENTATION FILE for the Class ClockType to overload the “= =”, i.e., the comparison “equal-equal sign,” here: That is, write the FULL FUNCTION DEFINITION for THE FUNCTION associated with Class ClockType to overload the “= =” remembering the private members are: b) int hr; // that contains the hours int min; // that contains the minutes int sec; // that contains the secondsSuppose that you are required to check if two tran carts have equal stacks of cargo. Explain how you are going to archieve this by overloading the equality operator. Create a function to overload this operator that accommodates any data type.