C++ :: User Input Data About Percentages To Calculate Final Grade - Addition Error?

Sep 15, 2014

I am trying to code a program that takes in user inputted data about percentages and using it to later on calculate a final grade. 4 percents are inputted, for Assignments, Midterm1, Midterm2, and Finals. If the percents dont add up to 1 (i tell the user to enter the decimal value) I set up and if statement to catch it and end the program. Except that if i type in

Assignments = .3
Midterm1 = .3
Midterm2 = .3
Finals = .1

the program doesn't recognize that they add up to 1. Heres the relevant portion of my code [URL] ....

Here's some examples of how it works [URL] ....

And heres what i dont understand [URL] ....

Why is it saying .3 + .3 + .3 + .1 != 1 when .1 + .3 + .3 + .3 == 1?

View 1 Replies


ADVERTISEMENT

C :: Calculate Final Grade By Adding 4 Numbers Minus Lowest Grade And Dividing By 3

Apr 7, 2013

I'm writing a program to calculate a final grade by adding 4 numbers minus the lowest grade and dividing by 3. My knowledge in c is not extensive I thought that a simple assigment operator would do the job but I'm getting a strange large numbers in the execution.

Code:
#include <stdio.h>
#include <stdlib.h>
main(){
int eg, g1, g2, g3, g4, fg, s1, s2, sg;

[Code] ....

View 4 Replies View Related

C/C++ :: Display Final Results Of Grade Calculation

Sep 14, 2014

I had to write a simple program that prompted the user for various test scores and it would pump out his grade average at the end. I did that with no issue, however, my instructor wants me to add something to the end off the code and I'm not sure how to do that. My code is:

#include <iostream>
#include <iomanip>
using namespace std;
int main() {
string tempType;
float SumTest, MaxTest, TestAve,ProgAve,output;
[Code] ....

And this is what I'm supposed to add, the averages are supposed to have numbers from what the user gave.
***************************
Grade Calculator

Program Average
Test Average

Final Grade
***************************

View 6 Replies View Related

C++ :: Recursive Function - Prompt User To Input Base And Exponent Then Generate Final Answer

Oct 31, 2014

I am studying about recursion by myself and i want to make a recursive function that prompts the user to input the base and exponent and generate the final answer .

#include<iostream>
using namespace std;
int recursive(int x, int y);
int main() {
/*int total=1;
int y, x;

[Code] .....

View 4 Replies View Related

C++ :: Program Should Input Each Student Grade As Integer And Store Grade In Vector

Jun 26, 2013

I get so close, and then it seems my brain shuts down ... I need to write a program that outputs a histogram of student grades for an assignment. The program should input each student's grade as an integer and store the grade in a vector. Grades should be entered until the user enters -1 for a grade. The program should then scan through the vector and compute the histogram. In computing the histogram, the minimum value for a grade is 0, but your program should determine the maximum value entered by the user. Use a dynamic array to store the histogram. Output the histogram to the console. For example, if the input is:

20
30
4
20
30
30
-1

Then the output should be:

Number of 4’s: 1
Number of 20’s: 2
Number of 30’s: 3

I can't quite get my output to look like that:

/* This program will display the histogram of student grades for an assignment */
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <conio.h>

[code]......

View 3 Replies View Related

C++ :: Calculate Complex Numbers Through Multiplication And Addition

Feb 28, 2013

Below is a code that is used to calculate complex numbers (a+bi, where i = sqroot (-1)) through multiplication and addition.

However, on my output file, no Header is being printed; the only thing that is being printed is "8 + 7i + = "

"complex.h" is included at the end of the code.

Code:
// Trey Brumley// CMPS
// Dr. Tina Johnson
// March 1, 2013
// Program 2: Classes
// This program will demonstrate the use of classes by using a custom "complex-number" (a+bi) class.

[Code] ......

View 4 Replies View Related

C/C++ :: Array To Only Print Out Final Average And Final Maximum Score With Final Minimum Score

Aug 27, 2014

#include <stdio.h>
float total, avg, max, min;
float judge[4];
int index;
int array[4];
int main() {
total = 0.0;
max = array[0];
min = array[0];

[Code] ....

I dont understand how to make the array when it prints out only print out the final average and the final maximum score with the final minimum score but what its doing at the moment is just giving an average for each individual score taken...

Minimum and maximum scores are displaying 0.0

And it displays these things 4 times in a row i just want it to be displayed once.

View 1 Replies View Related

C/C++ :: Calculate Cost From Wholesale To Final With Percentage Markup

Apr 15, 2014

Program calculates cost from wholesale to final cost with percentage markup!

#include <iostream>
using namespace std;
int calculate_retial(int,int);
int main () {
int wholesale;
int markup;
int cost;

[Code] ....

View 5 Replies View Related

C :: Program To Calculate Final Value Of Investment Made In TSX Market Linked GIC

Feb 20, 2013

Write a C program that calculates the final value of an investment made in a TSX Market Linked GIC.

Specification

The return on this type of GIC (Guaranteed Investment Certificate) is based on the initial investment, the number of years (1, 2 or 3), a minimum return rate, a maximum return rate, a participation rate, the values of the TSX (Toronto Stock Exchange) index at specified intervals during the years, and the type of averaging of these values. The final investment value can only be calculated once all the TSX values are known.

If averaging is not used the TSX rate is determined from the opening and closing values only. If averaging is used the TSX rate is determined by calculating the TSX average at 6 monthly intervals, then is based on this average relative to the opening value. The TSX rate is then multiplied by the participation rate. If this new rate is below the minimum rate, then the minimum rate is used, and if it is above the maximum rate, then the maximum rate is used. Rates are printed to 2 decimal places, and the final investment is rounded down, and formatted using commas.

Only round down for the final investment. If the TSX rate is negative do not print the line for rate adjusted for participation. Assume that the final investment is less than one million dollars. (Hint: if you need to print leading zeros in a number, use the %0m.n format: example - the format specifier %06.2f prints 4.56 as 004.56)

Example 1: See below; averaging is not used, so TSX rate = (107-100)/100 = 7%. After using a participation rate of 80%, get 5.6% (which is between min & max rates).

Example 2: See below; averaging is used over 5 values to get a rate of 68% which equals 54.4% due to participation. This is more than the max rate, so the max rate is used.

The GIC calculator must use the following layout exactly.

+------------------------------------+
| TSX MARKET LINKED GIC CALCULATOR |
+------------------------------------+
Enter initial investment : 1000.00
Enter number of years [1,2,3] : 3
Enter minimum and maximum rates [%] : 1 20
Enter participation rate [%] : 80
Enter if averaging used [1=yes,0=no]: 0
Enter open and close values : 100 107

TSX rate . . . . . . . . . . . . . . 7.00%
Rate adjusted for participation . . 5.60%

Final investment . . . . . . . . . . $ 1,056.00

+------------------------------------+
| TSX MARKET LINKED GIC CALCULATOR |
+------------------------------------+
Enter initial investment : 2000.00
Enter number of years [1,2,3] : 2
Enter minimum and maximum rates [%] : 1 20
Enter participation rate [%] : 80
Enter if averaging used [1=yes,0=no]: 1
Enter 5 TSX values : 200 190 320 430 540

TSX rate . . . . . . . . . . . . . . 68.00%
Rate adjusted for participation . . 54.40%
Maximum rate is applicable . . . . . 20.00%

Final investment . . . . . . . . . . $ 2,040.00 i wrote something like

Code:
#include <stdio.h>
int main (void)
{
int years, minimum, maximum, partrate, x, open, close, tsxvalue;
float investment, tsxrate, y, finalinvestment, maxrate, minrate;
printf("+------------------------------------+

[Code] ....

I don't know what the exact calculation should be here now to get the rest....so I'm stuck here

View 2 Replies View Related

C++ :: Two Dimensional Array - Calculate Final Scores Per Diver Who Each Get Five Dives

Jan 31, 2014

I have to create a program that calculates the final scores per diver, who each get five dives. I have to include the difficulty level when figuring out this score, and I need to drop the highest and lowest scores.

Now, I'm reading from a file where the values are something like:

234 :Diver number
2.3 :Difficulty
2.1 3.2 4.0 2.3 3.8 :Scores

Would I create a parallel array for the difficulty, or include it in a 2D array with the scores. Something like

score[Difficulty][individualScores]; ?

Also, would I include a findMin and findMax in a function that calculates the total, seeing as how the highest and lowest must be dropped to determine the final score?

View 11 Replies View Related

C++ :: Program To Call Relevant Functions To Calculate Final Price

Sep 14, 2014

I want this programming to call functions choose between a customer type and call the relevent function to calculate the final price but it is not calling the functions.

#include <iostream>
using namespace std;
double amount;
double studendOrPensioner(int&choice, double &origPrice);
double OtherCustomers(int&choice,double& origPrice);

[Code]...

View 1 Replies View Related

C/C++ :: Program That Calculate PI Based On User Input For Accuracy?

May 24, 2014

I am trying to create a program that will calculate pi based on a user input for accuracy. If the user input .3 then when the leibniz infinite sum value at a particular i becomes less then the input of .3 then the loop will exit.

I have looked at a number of examples on the internet but I feel lost. I have put together working code that will infinitely output sums but I need the loop to stop when the sum value is less then the accuracy value.

My question is what is wrong with my while loop, why will it only give me infinite summations? How do I make it so that the loop will exit when my accuracy input is greater then the sum?

int main () {
double accuracy;
cout<<"Give an accurate number." << flush;//looks nice
cin>>accuracy;
int d;//initialize denominator
double pi = 0.0;
while(accuracy < d){

[Code]...

View 8 Replies View Related

Visual C++ :: Program That Take Input From A User And Calculate It In A Do While Loop

May 15, 2013

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.

#include <iostream>
#include <cmath>
using namespace std;
double original_cost;
double discount;
double tax;
double total;
char answer;

[Code]...

View 2 Replies View Related

C++ :: Program To Calculate A Grade Letter Into Number?

Feb 7, 2013

So I have to write a program to calculate a grade letter into a number.

Letter grades are A, B, C, D, and F, possibly followed by + or –. Their numeric values are 4, 3, 2, 1, and 0. There is no F+ or F–. A + increases the numeric value by 0.3, a – decreases it by 0.3. If the letter grade is illegal (such as "Z"), then your output should be "INVALID LETTER GRADE"; If the combination is illegal (such as "A+" or "F-") then your output should be "INVALID GRADE COMBINATION"

Also the code should look like this
Enter your letter grade: C+
Grade value is [2.3]

// Input
cout << "Enter your letter grade: ";
string s;
cin >> s;

[Code].....

View 2 Replies View Related

C :: Calculate Different Measurements For A Cylinder - Width Modifier For End User Input

Sep 12, 2013

I have created a program to calculate different measurements for a cylinder. Anyways, the end user has to input 3 variables.

Enter the lower radius: 6
Enter the upper radius: 5
Enter slant height: 2.236

The numbers are what "End User" would input. But I need to make it look like this when said "End User inputs the numbers.

Enter the lower radius: 6
Enter the upper radius: 5
Enter slant height: 2.236

Here is what I have for it, but I don't know what to put where.

printf("
Enter the lower radius: ");
scanf("%f", &lower_rad);
printf("Enter the upper radius: ");
scanf("%f", &upper_rad);
printf("Enter slant height: ");
scanf("%f", &slant_h);

View 1 Replies View Related

C++ :: User Input - Calculate Sum Of Only Positive Values While Ignoring Negative Numbers

Jun 19, 2014

So I have to make a program that allows the user to enter both positive and negative numbers and the program is suppose to calculate the sum of only the positive values while ignoring the negative values. Also it is to be a sentinel-controlled loop with a number ending the set of values.

View 4 Replies View Related

C++ :: Program To Calculate Total Grade For N Classroom Exercises As Percentage

Mar 5, 2013

Write a program that calculates the total grade for N classroom exercises as a percentage. The user to input the value for N followed by each of the N scores and totals. Calculate the overall percentage (sum of the total points earned divided by the total point possible) and output it as a percentage. Sample input and output it as a percentage. Sample input and output is shown below.

How many exercises to input?
score1: 10
total points possible: 10
score2: 7
total points possible: 12
score3: 5
total points possible: 8

Code:
# include <iostream>
using namespace std;
int main () {
double N=0, score, total, totalScore=0, totalGrade=0, GRADE;
cout<<"How many excersices will be scored?/n";

[Code] .....

Error:
1>------ Build started: Project: HOMEWORK5, Configuration: Debug Win32 ------
1>LINK : error LNK2001: unresolved external symbol _mainCRTStartup
1>C:UsersWORKHOMEWORK5DebugHOMEWO… : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

View 4 Replies View Related

C++ :: User Input Two Numbers - Calculate Square Root Then Roots Are Added Up To Return Sum

Aug 23, 2014

I have tried writing a code which takes two numbers from the user and calculates their square root then the roots are added up to return the sum. The program is coming out with loads of errors.

#include<iostream>
#include<cmath>
float main(){
using namespace std;
float m1,m2,m3,m4,m5;

[Code] ....

View 4 Replies View Related

C++ :: Store User Input In Array And Calculate Mean / Median And Mode - Bubble Sorting

Mar 26, 2014

I'm trying to make a c++ program of this but i don't know how to use the bubble sorting.

Write a C++ application that asks the user to enter 10 numbers. The program then stores those numbers in an Array. The program should display the Mean , Median, and Mode.

Mean is the average of the 10 numbers.
Median is the average of the 5th and the 6th numbers. (But you have to arrange the numbers in ascending order first using Bubble Sort before calculating the Median.)
Mode is the most frequent number among the 10 numbers.

View 5 Replies View Related

C++ :: Dynamic Arrays - Sort Input Data And Calculate Average

Jul 15, 2014

I'm still fairly new to c++ and am having trouble with dynamic arrays. My task is to create an array for test scores. The user needs to define the size of the array and then input data to later sort and calculate the average.

Below is what I have so far. I am struggling with the user input part. I receive the following errors for the data input of the individual scores:

"error C2108:subscript is not of integral type"
"IntelliSense:expression must have integral or unscoped enum type"

Code :

#include<iostream>
#include<iomanip>
using namespace std;
int main() {
//user input total number of scores
cout<<"Please enter the total number of test scores."<<endl<<endl;

[Code] ....

View 1 Replies View Related

C :: Generate A Program That Will Allow User To Enter Data For A Stock And Calculate Amount Of Stocks

Oct 5, 2013

Okay, so my assignment for my C class is to generate a program that will allow the user to enter data for a stock and calculate the amount of stocks that ended up being positive, negative, and neutral.I tried to do this using one stock, here is my code;

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

Code:

void main()
{
float Neg;
float incst;
float shrs;
float bpps;
float crnt;
float crntcst;
float yrfes;
float pft;
float tpft;
}

[code]....

View 6 Replies View Related

C/C++ :: Final Output Needs To Print Initial And Final Values

Jan 28, 2015

I have a program that is reading six characters from a text file, swapping every other character(ABCD would read BADC), and then adjusting their value based on a user's adjusted value input. If the adjusted value is 5 then letter A becomes F.

The final output line should print the initial six characters followed by the final six characters after the swap and encrypt adjustment.

I can only manage to print the final characters. Am I far off thinking I need to use pointers to point to the original character values?

One more thing: instructor wants us to complete this project as simply as possible meaning without the use of arrays, loops, switch statements, etc.

#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main() {
//declarations
char c1,

[Code] ....

View 4 Replies View Related

C :: Addition And Subtraction Calculator That Takes Input?

Feb 23, 2013

I'm writing an addition and subtraction calculator that takes input as: 5+6-3+2. You should be able to add or sub as many numbers as you want. I want the while loop to stop when the user hits enter. I put the getchar() function to catch the and break the loop but it is also swallowing the '-' sign, which I want to use to subtract and is instead adding the numbers with "sum+=number". How can I get around that?

Code:

#include <stdio.h>
int main(int argc, char *argv[]){
int number, sum = 0;

[Code]....

View 3 Replies View Related

C++ :: Generates Random Addition For Subtraction Depending On User Choice

Feb 17, 2012

Below is a program that generates random Addition for Subtraction problems depending on the user's choice. The user is prompted to input an answer and then it keeps your score. If you want to quit you just press zero.

Code:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iomanip>
#include <string>
using namespace std;
int menu();
bool addition(int &reward); // function to return truth values

[Code] ....

View 14 Replies View Related

C :: Unscramble User Input - Error In Loop

Sep 24, 2014

The purpose of this program is to unscramble the user's input. for example if the user entered 'ftooabll' the program would print 'football'. find the error that I am making....

Now, this only works for strings that are contained in the file wordlist. That being said, I would like this to repeat this search multiple times. Currently, the process is being repeated 7 times, but it only works on the first iteration. The code and sample input/output is below.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NUMLOOP 6
void sort_string(char*);

[Code] ....

Sample input/output: (note: all data has been verified to be in the wordlist)

Enter string:
4132dcba
abcd1234
Enter string:
4132dcba
Enter string:
4132dcba
Enter string:
4132dcba
Enter string:
4132dcba
Enter string:
4132dcba
Enter string:
4132dcba

View 3 Replies View Related

C++ :: How To Error Check If User Input Is Letters And Not Numbers

Jun 9, 2014

How do I error check if the user is inputting letters and not numbers? For example, if the user inputs "Lab.txt" I need to display an error message. If they input "Lab2part2.txt" then this is correct and what I want.

I've found a lot of information online on how to error check for numbers or a single letter (EX: 1,2,3, etc. or 'A' 'B' 'C') but nothing for actual WORDS or maybe I should refer to it as a string of characters?

Is there any way to do this? Because my program requires I ask the user to input the name of the file. But the way my code is currently set up is even when the user inputs the wrong file name it still opens the file. I want to prevent this from happening so my thought was to error check user input.

/*Program to determine company's weekly payroll*/

#include <iostream>
#include <string>
#include <fstream>
using namespace std;
void OpenTheFile() {
ifstream inputFile;
string filename;
char letter;
int number;

[Code] .....

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved