Must make a "Calculator" using C. The calculator must subtract, add, divide, and multiply inputs, and tell whether a number is prime or not. The user chooses how many inputs go into the calculator.
For example, the code will ask the user what function they want. If the user chooses to subtract, the the code will then ask the user how many numbers they want to subtract. After, the code will ask the user to input as many numbers as they chose in the last step. Lastly, the code must subtract the first input - the second input - the third input and so on, and must print the answer.
In: Computer Science
in c code
For example, a sample execution of your code would be as follows:
Cookie Corner! (name it whatever you want)
Please enter your first name.
Jane
Jane, what type of cookie would you like to order?
1
You selected a SUGAR cookie. How many cookies would you like?
4
Jane, your total cost is $1.00
Would you like to order another type of cookie?
No
Thanks for ordering!
In: Computer Science
In Chapter 4 of your book, you created an interactive application named MarshallsRevenue that prompts a user for the number of interior and exterior murals scheduled to be painted during a month and computes the expected revenue for each type of mural. The program also prompts the user for the month number and modifies the pricing based on requirements listed in Chapter 4.
Now, modify the program so that the user must enter a month value from 1 through 12. If the user enters an incorrect number, the program prompts for a valid value. Also, the user must enter a number between 0 and 30 inclusive for the number of murals of each type; otherwise, the program prompts the user again.
Below is the source code
using System;
class MainClass
{
public static void Main (string[] args) //main function
{
//variable declaration
int month,intmu,extmu,total;
total=0;
string[] arr = new string[] {"January", "February", "March", "April", "May",
"June", "July", "August", "September", "October", "November", "December"};
do
{
//accepting the month value from user
Console.WriteLine ("Enter a month number");
month = Convert.ToInt32(Console.ReadLine());
if(month<1 || month >12)
Console.WriteLine ("Enter a valid value between 1 to 12");
}while(month<1 || month >12);
do
{
//accepting interior mural number from user
Console.WriteLine ("Enter number of interior murals");
intmu = Convert.ToInt32(Console.ReadLine());
if(intmu < 0 || intmu >30)
Console.WriteLine ("Enter a valid value between 0 to 30");
}while(intmu < 0 || intmu >30);
do
{
//accepting exterior mural number from user
Console.WriteLine ("Enter number of exterior murals");
extmu = Convert.ToInt32(Console.ReadLine());
if(extmu < 0 || extmu >30)
Console.WriteLine ("Enter a valid value between 0 to 30");
}while(extmu < 0 || extmu >30);
//displaying the data
Console.WriteLine ("Revenue for the month of "+arr[month-1]);
Console.WriteLine("Number of interior murals : "+intmu);
Console.WriteLine("Number of exterior murals : "+extmu);
//calcultaing the total revenue
total=(100*intmu)+(200*extmu);
Console.WriteLine("Total Revenue : Rs "+total);
}
}
Please provide source code and display response.
In: Computer Science
Prove the following using the properties of regular expressions:
In: Computer Science
In: Computer Science
Let X = {x1,x2,...,xn} a sequence of real numbers. Design an algorithm that in linear time finds the continue subsequence of elements xi,xi+1,...,x, which product is the maximum. Suppose that the product of an empty subsequence is 1 and observe that the values can be less to 0 and less to 1.
In: Computer Science
Comment the code explaining what each line is doing. The first line has been done for you.
x=[0 0 -1 2 3 -2 0 1 0 0]; %input discrete-time signal
x dtx= -2:7;
y=[1 -1 2 4];
dty=8:11;
z=conv(x,y);
dtz=6:18;
subplot(1,3,1), stem(dtx,x)
subplot(1,3,2), stem(dty,y)
subplot(1,3,3), stem(dtz,z)
In: Computer Science
Use the cumsum command in MATLAB to show that the cumulative sum of an impulse is a unit step function. Add a line to your code from Problem 2. Plot the unit step function generated by the cumsum command. Turn in a copy of the code and graph.
In: Computer Science
In: Computer Science
In one paragraph, please briefly explain why cloud customer should use AWS KMS.
In: Computer Science
Use one sentence to briefly describe the difference between symmetric encryption and asymmetric encryption.
In: Computer Science
Resource Monitor. Windows 10
Uncheck perfmon.exe.
In: Computer Science
C++
// Program Description: This program accepts three 3-letter words and prints out the reverse of each word
A main(. . . ) function and the use of std::cin and std::cout to read in data and write out data
as described below.
Variables to hold the data read in using std::cin and a return statement.
#include <iostream >
int main(int argc, char *argv[]) {
.... your code goes here
}//main
Example usage:
>A01.exe Enter three 3-letter space separated words, then press enter to display the reverse: cat eye fix tac eye xif Enter any key to exit:
In: Computer Science
Python
Problem 4. Estimate pi version 2: write a program that will quickly estimate pi to a precision of 1e-4 using a monte carlo approach. Your program should employ a loop where each iteration produces a new x,y pair. One will then determine whether the x,y pair lies inside or outside the circle. (see below) Since all the points will land within the square shown above but only a fraction will land within the circle, we can estimate pi by relating the area of the quarter circle shown above to the area of the square. As we randomly choose points, we can determine if they fall within the circle or not and form a ratio as shown below: AreaQtrcircle / AreaSqaure = πr 2 / 4r 2 = π / 4 = Points in Circle / All Points, π ≅ 4* Points in Circle / All Points.
Your loop should continue until the absolute value of the difference between the current estimate and the previous estimate is less than 1e-4. The program should output the estimate of pi and the number of iterations (points) needed to reach the desired level of precision. Run your program several times to see if the number of points changes. Note any observations in the comments.
In: Computer Science
(In Java) Implement a Deque in which addFirst(), addLast(), removeFirst(), removeLast(), and getMin() are all in O(1) (amortized). The getMin() method is supposed to find the minimum value in the deque and update after ever add/remove. I tried implementing this with a Deque and LinkedList but wasn't successful, you do not need to use either. Must use the comparator and iterator. The goal is to be as fast as possible, so this includes avoiding any operations that aren't O(1) as much as possible. I used my own testing class. Thanks!
import java.util.*; public class FMinDeque<T> implements MinDeque<T> { protected Comparator<? super T> comp; Deque<T> dq; protected List<T> min; T m; public FMinDeque() { this(new DefaultComparator<T>()); } public FMinDeque(Comparator<? super T> comp) { this.comp = comp; dq = new ArrayDeque<T>(); min = new LinkedList<T>(); } public Comparator<? super T> comparator() { return comp; } public void addFirst(T x) { } public void addLast(T x) { } public T removeFirst() { return null; } public T removeLast() { return null; } public T getMin() { } public int size() { return dq.size(); } public Iterator<T> iterator() { return dq.iterator(); } }
This extends:
import java.util.Comparator; public interface MinDeque<T> extends Iterable<T> { public Comparator<? super T> comparator(); public void addFirst(T x); public void addLast(T x); public T removeFirst(); public T removeLast(); public T getMin(); public int size();
And
import java.util.Comparator; class DefaultComparator<T> implements Comparator<T> { @SuppressWarnings("unchecked") public int compare(T a, T b) { return ((Comparable<T>)a).compareTo(b); } }
In: Computer Science