So I'm currently using Visual Studio 2013, and I was left for homework as a beginner programmer to calculate two summations. First the summation of k to n. k=1 and the equation being k^3. The parameter would be n and I need to printf the results for n=5, 33, 100, 442, 3456.
I know that some of the numbers are big values so float or long should be used but how to define these as of yet.
Another is to find the summation (n) (k) <<-- one big paranthesis
for values k=8 and n=10, 21, 35, 46, 68
How to start excluding <stdio.h> and int main ... Also, do I have to repeat a new function for every number for n?!
This is what I have so far for something I did differently
// Factoriales Sumatorias
#include <stdio.h> int suma1 { int n = 5; // Defino e Inicializo la variable long sumatoria = 1; // definicion e inicializacion del resultado while (n <= 5)
I've been trying to calculate the Second standard deviation but the average in the second loop isn't calculating correctly which is causing the standard deviation (method 2) to not calculate correctly.
Code: #include <iostream> #include <iomanip> #include <string> #include <fstream> #include <cmath> using namespace std; int main () { cout << " This program will produce statistics (Mean, Standard Deviation, "
Write a C++ program to calculate the fewest number of each denomination needed to pay a bill of amount TOTAL. For example, if the end user enters $97 for TOTAL, program will output that the bills would consist of one $50 bill, two $20 bills, one $5 bill, and two $1 bills. (Assume that the amount is in whole dollars, no cents, and only $100, $50, $20, $10, $5, and $1 denominations are available.) Aid: You may want to use the modulus operator %.
So if i write a Loop to calculate Prime Numbers in order, is there any way possible for this to happen in a shorter period of time.
The loop that i constructed took about 11hrs on a Win 7 2GB ram machine to calculate about 150,000 primes, could this be done any faster................
I'm trying to create a program that will take input from a user and calculate it in a do-while loop. The program does the calculation but the answer is wrong. The loop also doesn't work. The purpose of the program is to see how much an item will cost after a discount is taken off and tax is added.
My question is, I have been tasked to draw this shape,
![Crescent Moon][URL] ....
This is to be done using C++ to write code that will calculate the points on this shape.
Important details.
User Input - Centre Point (X, Y), number of points to be shown, Font Size (influences radius)
Output - List of co-ordinates on the shape.
The overall aim once I have the points is to put them into a graph on Excel and it will hopefully draw it for me, at the user inputted size!
I know that the maximum Radius is 165mm and the minimum is 35mm. I have decided that my base [Font Size][1] shall be 20. I then did some thinking and came up with the equation.
Radius = (Chosen Font Size/20)*130. This is just an estimation, I realise it probably not right, but I thought it could work at least as a template.
I then decided that I should create two different circles, with two different centre points, then link them together to create the shape. I thought that the INSIDE line will have to have a larger Radius and a centre point further along the X-Axis (Y staying constant), as then it could cut into the outside line.*
*(I know this is not what it looks like on the picture, just my chain of thought as it will still give the same shape)
So I defined 2nd Centre point as (X+4, Y). (Again, just estimation, thought it doesn't really matter how far apart they are).
I then decided Radius 2 = (Chosen Font Size/20)*165 (max radius)
So, I have my 2 Radii, and two centre points.
This is my code so far (it works, and everything is declared/inputted above)
for(int i=0; i<=n; i++) //output displayed to user { Xnew = -i*(Y+R1)/n; //calculate x coordinate Ynew = pow((((Y+R1)*(Y+R1)) - (Xnew*Xnew)), 0.5); //calculate y coordinate
[Code] ....
I am having the problem drawing the crescent moon that I cannot get the two circles to have the same starting point?
I have managed to get the results to Excel. Everything in that regard works. But when i plot the points on a graph on Excel, they do not have the same starting points. Its essentially just two half circles, one smaller than the other (Stops at the Y axis, giving the half doughnut shape).
If this makes sense, I am trying to get two parts of circles to draw the shape as such that they have the same start and end points. Currently all I am getting more a 'half doughnut' shape, due to the circles not being connected.
I need coding this project using while loops and cout/cin.. It is suppose to be one while loop for the whole thing and inside of the first while loop is the second while loop for each sale separately.
You have been asked to write a program to calculate sales totals for a general store. Your program will not know how many products each customer will buy, so your program will have to repeat the process until the last product has been entered (use -1 for Product ID to end each sale). After each sale your program must ask if you want to do another sale (Y - continue, N - end program).
At the beginning of the day, the cash drawer has $500 in it. At the end of the program you must display how much money is in the drawer after handling all your sales transactions.
Input Your program must take the following input: - Product ID Number (int) - Quantity for each item purchased (int) - Cash Received at the end of the sale
Use the following dataset to determine the price and taxability for each item.
First Sale: Product ID Price Quantity Taxable 101 $65.00 2 Yes 102 $12.50 1 No 103 $24.50 5 No 104 $38.75 4 Yes 105 $17.80 6 Yes 106 $16.50 2 No 107 $42.85 8 Yes 108 $32.99 2 Yes 109 $28.75 1 Yes 110 $51.55 1 No
Second Sale: Product ID Price Quantity Taxable 102 $12.50 1 No 103 $24.50 1 No 106 $16.50 1 No 107 $42.85 1 Yes 108 $32.99 1 Yes 109 $28.75 1 Yes
Third Sale: Product ID Price Quantity Taxable 106 $16.50 4 No 107 $42.85 3 Yes 108 $32.99 1 Yes 109 $28.75 5 Yes 110 $51.55 2 No
Calculating Tax For those items that are taxable, assume a 7.5% sales tax. Be sure to keep a running total of tax for the each sale.
Getting Started You must use the starter file provided with this assignment. What to turn in: - A copy of your source code - A printout of your program's output
The point of this is to calculate the total of the monthly costs of these 6 expenses and then to show the annual cost. However, there's just a couple of things that's giving me problems and it's the calcMonCost in my code. The error says that it is more than one instance of overload function and also that an unresolved external symbol. Everything else is fine. What does this mean?
Write a program in C++ that calculates the amount to be paid to an employee based on the hours worked and rate per hour. A user will enter hours worked and rate per hour for an employee. Your program should have a function payCheck that calculates and returns the amount to be paid. The formula for calculating the salary amount is as follows: for the first 40 hours, the rate is the given rate (the rate that a user has entered); for hours over 40, the rate is 1.5 times the given rate.
I had write my own coding, but it keeps error. it is okay. But i still don't think i could share here? Still running... I will update my coding for you alls to check for any syntax or logic error. The problem is i need to calculate if the employee work for more than 40 hours which 1.5 times.
Write a function that computes the Taylor series expansion of ex using the following formula, where x is the exponent, and n is the number of discrete trials to run: ππ₯=1+π₯+π₯2+π₯3+π₯4+β―+π₯π =βπ π₯π 2! 3! 4! π! π=0 π! NOTE: This formula will NOT work if you calculate the numerator and denominator separately and then add the division result. You must use your knowledge of algebra to make sure youβre not calculating the entire exponent and factorial, but rather their factors per loop iteration.
Input prompt Enter the values for x and n: Output Prompt Taylor series estimation is XXXX.XXXX
This is what I have so far for the function:
void getTaylor() { double estimation cout << "Enter the values for x and n:" << endl; cin >> x >> n; cout << "Taylor series estimation is" << }
I now need to create the loop so that I can enter in for my function.
Write a program that approximates the value of Ο using the Leibniz series and compares the Leibniz series approximation against the known value of Ο and two other common approximations of Ο (22/7 and 355/113). The program must prompt the user for the desired number of terms (n) to use in the approximation (as an integer) and calculate the approximate value of Ο to the given number of terms. The program must display each approximation of Ο and display the difference between each approximation.
I understand how to prompt for the number, what I don't even get how to start is to use it to approximate the value of pie in that given number. Also how to tell the difference between each approximation...
I can't seem to get the math portion right. It is supposed to approximate pi using (sigma,i=-1 to infinity)(-1)^(i+1)(4/(2i-1))=4(terms of pi). And what I have does some math but it is incorrect because I get a negative value for pi and one that is entirely too large at that. The precision is also to be at 20 decimal places. I also need it to end immediately after if I get an invalid input, but I can't seem to get it to end after trying a few different things it will say that it is an invalid number, but will continue to run the math loop. I also need the final cout to print all the terms that is multiplied by 4.
[code]#include <iostream> #include <cmath> #include <iomanip> using namespace std; int main() { int nterm, numerator; double sum = 0.0; const int upperBound = nterm * 2; cout<<"This program approximates pi using an n-term series expansion. "<<endl;
I'm attempting to print a series of text from this loop, but for some reason all I am getting is the sum total and the number 1, like this
1 5175.11
When I want to get it for each iteration of the loop. I've cycled over this and compared it to my other loops I've used and I'm lost as to why this isn't working. I also tried using a do while but that didn't work as well.
I'm having trouble, I want the inner loop to display the lowest and highest score. If I assign initial values for the high and low score, it won't always work (because if no/ all scores are above/ below my initial values...)
But without assigning initial values for highscore and lowscore, One of them will always be undefined during the first runthrough.
#include <iostream> using namespace std; const int AGRADE = 90; const int BGRADE = 80; const int CGRADE = 70; const int DGRADE = 60; int main() {
[code]....
how do i set this up so it stores a low and high score, and then compares those to each next number in the series?
I need to write a program that not only calculates the minimum and maximum, but also calculates the average and the difference between the largest and the smallest.
How to remake the code that i`ve written to have : a recursive function to evaluate the first n terms in series specified y= 1 - x + x^2/2 - x^3/6 + x^4/24 +....+(-1)^n x^n/n!
And this is my code:
#include <iostream> using namespace std; double power(int n, double x) { double d =1; for (int i = 1 ; i<=n ; i++)