In: Computer Science
Code: please use in visual studio 2019 c++ (not java)
In total you will write 6 functions:
Functions :
A ) addInts, returns int; input is two ints; Add the values of the two parameters and return the sum
B) subInts , returns int; input is two ints; Subtract the values of the two parameters and return the difference
C) multInts, returns int; input is two ints; multiple the values of the two parameters and return the product
D) divInts, returns int; input is two ints; Divide the values of the two parameters and return the quotient
E) modInts, returns int; input is two ints; compute the residual of the values of the two parameters and return the residual
F) A function called computeOperation ( ) that , returns an int; input is three parameters: one 'control' int, and two ints;
if the control int ( the first parameter) is :
Control
Control Parameter | compute return value : |
1 | Return sum of 2nd and 3td parameters |
2 | Return diff of 2nd and 3td parameters |
3 | Return product of 2nd and 3td parameters |
4 | Return quotient of 2nd and 3td parameters |
5 | Return modulus of 2nd and 3td parameters |
expect to see both Function Declarations and of course the Function Definitions for all 6 functions
expect to see some obvious test code or data sets.
expect to see a switch statement not a series of if statements if it is appropriate.
To Be Clear:
in the main function there should be a homework header and then a bunch of 'call's to the
computeOperation ( ) function.
And
computeOperation should then have code to invoke one of the 5 low level compute functions. The value that is returned should be returned by computeOperator.
In: Computer Science
Find the statistics for a single quantitative variable by utilizing Encapsulation and Namespace functions:
Each function should accept a list as an input parameter:
List = [1,2,3,4,5,6]
Functions : lst_min, lst_max, lst_range, lst_variance, lst_stdev.
Use: Python programming language, please. (Note: without inbuilt function)
Thank you.
In: Computer Science
Are Gradient boosting model, Random Forest, XGBoost, and LightGBM all tree-based models??
Thanks!
In: Computer Science
Code in C++
Learning Outcomes
Implement two stacks and use them to implement an infix to prefix expression convertor
Stacks
A stack is an abstract data type which uses a sequential container and limits access to that container to one end. You may enter or remove from the container, but only at one end. Using the Linked List data structure from your last homework assignment, implement a Stack of type string.
The Stack should only have one data member: the Linked List. It should implement the following methods:
Your linked list should support adding to the end of the list.
Infix to Prefix Conversion
Suppose you have an infix expression a+c^d/g-h. Using the math operation priority, we learned this is equal to a+(((c^d)/g)-h).
The prefix expression of the above infix one is: + a - / ^ c d g h
Your program must read a math expression in string and prints its prefix equivalent.
An example of program run:
Please enter the infix math Expression: a+c^d/g-h
The equivalent prefix math expression is : + a - / ^ c d g h
Do you want to add another expression [Y/N]: Y
Another example of the program in which program returns an error message.
Please enter the infix math Expression: a++c^d/g-h
Sorry! The expression is not valid.
Do you want to add another expression [Y/N]: Y
The user must use * to declare the multiplication, and ^ to declare power.
The only valid operators are: ^ * / + -
User may enter ( and ) as many as they want provided the expression is correct. For example, the following expression is valid:
(((((((a+b)))))))+((((c))))
And the output must be: + + a b c
Program must treat variables such as ab as one operand and not the multiplication of a and b. (ab!=a*b)
See following example:
Please enter the infix math Expression: aa+c^dsa/gl-h
The equivalent prefix math expression is : + aa - / ^ c dsa g h
The aa and dsa are two operands.
Rules for Implementation
Start at the beginning of the expression string and evaluate each character based on these rules.
a+b*c the b and c are the operands of the * operator. Then * b c all together is an operand to the + operator (the other operand of this operator is a)
After all characters have been evaluated, perform one last check:
The InfixToPrefix Class
Create a new class called InfixToPrefix.hpp containing the following fields.
It will also have the following constructors and methods.
Write the Driver.
The program will begin with a single prompt: " Please enter the infix math Expression: "
The user will supply an expression. Next, the program will prints the prefix expression of the given expression. If the expression is not valid, report print that the expression is not a valid infix expression. Finally, the program will wait for a final keystroke (i.e. pause). Make sure that your program works for all of the sample expressions.
In: Computer Science
a. Encoding the decimal number 2.25 into an 8-bit binary. Suppose k=4 exponent bits, n=3 fraction bits, and the bias is 7. What’s the corresponding binary representation for 2.25? Show your work. b. What’s the value in decimal if this is an 8-bit floating point number? Suppose k=4 exponent bits, n=3 fraction bits, and the bias is 7 of 10111001
In: Computer Science
In: Computer Science
1. Convert the binary data “110101” into analog waveforms using following modulation techniques: a. Two level Amplitude Shift Keying b. Two level Frequency Shift Keying c. Two level Phase Shift Keying d. Differential Phase shift keying e. Four level Amplitude Shift Keying f. Four level Phase Shift Keying g. Eight level Amplitude Shift Keying
In: Computer Science
In: Computer Science
Using Python:
The Fibonacci sequence is a famous series of numbers with the following rules:
The first number in the sequence is 0 -
The second number in the sequence is 1 -
The other numbers in the sequence are composed by adding up the two previous numbers in the sequence. We therefore have the following sequence: 1 st number: 0 2nd number: 1 3 rd number: 0 + 1 = 1 4 th number: 1+1 =2 5 th number: 2+1 = 3 6 th number: 3 + 2 = 5 7 th number: 5 + 3 = 8 and so on….
a. Write a program that takes a value n from the user and , using recursive function, display the first n Fibonacci numbers. (3pts)
b. Then, using List Comprehension, indicate which of the first n Fibonacci numbers are (2pts) : - odd numbers - multiples of 5
Example: How many Fibonacci numbers do you want ? 2 The first Fibonacci numbers are : [0, 1] From this list, the odd numbers are : [1] There is no multiples of 5 in this list How many Fibonacci numbers do you want ? 5 The first Fibonacci numbers are : [0, 1, 1, 2, 3] From this list, the odd numbers are : [1, 1, 3] There is no multiples of 5 in this list How many Fibonacci numbers do you want ? 11 The first Fibonacci numbers are: [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55] From this list, the odd numbers are : [1, 1, 3, 5, 13, 21, 55] From this list, the multiples of 5 are : [5, 55] Note that 0 is neither an odd number nor multiple of 5
In: Computer Science
C++ Sort Vector of Strings (case-sensitive)
Without using libraries, how would I arrange a vector like this alphabetically?
vector words {"September", "test" "seven", "apple"}
The output should be: "apple, seven, September, test"
In: Computer Science
Use a recursive tree method to compute a tight asymptotic upper bound for recurrence function T(n)= 2T(n/5)+3n . then use substitution method to verify your answer.
In: Computer Science
Write the code that will produce the given "after" result from the given "before" starting point by modifying links between the nodes shown. Assume that the nodes have already been declared and initialized to match the "before" figure below. There may be more than one way to write the code, but do NOT change any existing node's data field value. Do not create any new nodes, you must just rearrange the existing nodes.
If a variable does not appear in the "after" picture, it doesn't matter what value it has after the changes are made. If a given node object does not appear in the "After" picture, you must free its memory to avoid a memory leak.
You should not be depending on the values of the nodes, the second test case here will test a list1->a->b->c->d (some other list of the values). And it must be re-arranged in the same way.
Before |
list1: 1 -> 2 -> 3 -> 4 / |
---|---|
After |
list1: 3 -> 2 / list2: 4 -> 1 / |
Assume that you are using the following ListNode structure:
struct ListNode {
int data; // data stored in this node
ListNode* next; // a link to the next node in the list
};
Edit here:
#pragma once
#include <iostream>
using namespace std;
struct ListNode {
int data;
ListNode* next;
};
void pointerFun(ListNode* &list1, ListNode* &list2)
{
// TODO: write your code here
}
In: Computer Science
Write a program that calculates and prints the bill for a cellular telephone company. The company offers two types of services: regular and premium. Its rates vary depending on the type of service. The rates are computed as follows:
Regular service: $10.00 plus the first 50 minutes are free. Charges for over 50 minutes are $0.20 per minute.
Premium Service: $25.00 plus
Your program should output the type of service, number of minutes the telephone service was used, and the amount due from the user.
For the premium service, the customer may be using the service during the day and night. Therefore, to calculate the bill, you must ask the user to input the number of minutes the service was used during the day and the number of minutes the service used during the night.
IN PYTHON PLEASE
In: Computer Science
If you are starting a now Online Ecommerce Business, do you think it’s important to run media on TV, Billboard and other offline media channels? Or would you only run media via Online channels?
In: Computer Science