C++ :: Looping And Calculate The Percentage?

Mar 7, 2013

#include <iostream>
#include <iomanip>
#include <math.h>

[Code].....

I AM HAVING TROUBLE CALCULATING THE PERCENTAGE. I HAVE TO CALCULATE THE AMOUNT OF MONEY FOR 6 YEARS.

View 1 Replies


ADVERTISEMENT

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/C++ :: Calculate Percentage Of Even Numbers Entered By User In Array

Nov 18, 2014

exercise in c: write a program which calculates % of even numbers entered by a user in an array;

1) check if user hasn't entered float value; if has issue warning;
2) give the option for user to press "stop" to exit program any time.

int c,sk[100],i,sum1=0, sum2=0, rel;
printf ("How many numbers will you enter?
");
scanf ("%d", &c);
printf ("Enter %d numbers (to exit program press - stop)
", c);

[Code] ....

View 1 Replies View Related

C/C++ :: Create Program To Calculate A Percentage For Commission And Bonus?

Feb 11, 2014

I am using codeblocks for school and I am trying to create a program to calculate a percentage for commission and a bonus. I have tried using a decimal for percentage, int and floats with casting. Every time it I try it displays 0 or just the bonus. I even took and did a test page. My head is about to pop.

Write an algorithm that can be used to calculate the commission earned in a real estate transaction. The chart below describes the formulas used to calculate the commission.

Sales Price Commission
Less than $100,000 5% of Sales Price
$100,000 to $300,000 $5,000 + 10% of Sales Price over $100,000
More than $300,000 $25,000 + 15% of Sales Price over $300,000

// Commission and Bonuses.
#include <iostream>
#include <iomanip>

[Code].....

View 2 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++ :: Calculate Percentage Of Times Coin Flipped Either Heads Versus Tails

Feb 10, 2015

I'm having trouble getting the program to calculate the percentage of times it flipped either heads versus tails. I realize what I currently have doesn't work because above I initialized heads and tails by giving them values of 0, but I'm unsure of how to fix it.

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main () {
srand(time(0));

[Code] .....

View 2 Replies View Related

C++ :: Dice (with Varying Number Of Sides) Program To Calculate Percentage Of Results

Oct 28, 2013

I am trying to code and compile a program that requests a uses to first inpu the number of sides they wish for a dice to have and secondly input the number of dice throws they would like to calculate the value for. The program will print an error message and default the number of sides the dice has to 5 if the number entered is below 4. Finally it will print out a percentage figure for each value that results from all the the dice rolls.

I have attached my header, driver and class files below along with accompanying error messages below them

// file name Exercise.cpp
#include <iostream>
#include "Die.h"
using namespace std;
int main() // the main program begins here
{
char restart = 'y'; // declare variables
double numRolls = 0.0;
int diceTot = 0;

[Code] .....

View 5 Replies View Related

C++ ::  Looping Simple Menu - Calculate Dimensions Of Floor Plan In Square Feet?

Oct 2, 2013

What I'm trying to accomplish is to ask the user what their floor plan is (in square feet), have them pick what kind of material they want and give them a general price.

Which is working out great so far, but I would also like to add a loop at the end that cycles back if they want to re-do the estimate with a different material selection and if not exit out the program.

I've been trying do while and if/else loops but i can't get them to work right.

#include <iostream>
#include <string>
using namespace std;
int main() {
string custName, selection;
int custNumber, floorSize, material, contactSystem;

[Code] ....

That's basically what I've come up with so far minus all the erroneous attempts. Though as is I technically complete the assignment, I would like the extra credit from making the last part loop.

View 1 Replies View Related

C++ :: Float Function Of Percentage

May 28, 2013

Below is the code of a program using classes and functions ,, my float function doesn't show answer in fractions ,, show something else...

#include <iostream>
using namespace std;
class khan{
public:
void print(){
cout<<"welcome to the online Addition System!!!" <<"

[Code] ...

View 6 Replies View Related

C++ :: Show Percentage When File Is Being Updated

Jun 19, 2014

I want to update a file but I want to show the percentage when it is being updated. How can I do this? Do I need to use threads?

View 2 Replies View Related

C++ :: Program To Display Percentage Of Calories Come From Fat

Mar 18, 2013

Write a program that asks the user to enter the number of calories and fat grams in a food item. The program should display the percentage of the calories that come from fat. One gram of fat has 9 calories, so:

(Calories from fat) = (fat grams) * 9

The percentage of calories from fat can be calculated as:

(Calories from fat) / (total calories)

Extend as follow

1. The user first enters from a menu whether it is breakfast (B or b), lunch (L or l) or dinner (D or d). Use character and process by a switch.
2. The threshold for low calorie is different, for breakfast 10%, lunch 20%, dinner 30% (this value has to be assigned to some threshold variable in the above switch).
3. Include validation of menu choice.
4. In case any validation fails, display detailed error and exit the program by calling return 1 or return EXIT_FAILURE
5. Display the % from fat with one decimal digit.

Example 1:
What you have to eat:
B - breakfast
L - lunch
D - dinner
What you have: C
Error: C is not a valid menu choice

Example 2:
What you have to eat:
B - breakfast
L - lunch
D - dinner
What you have: L
How many calories: 600
How many grams of fat: 10
Your food has 15.0% calories from fat
It is a low calories food

Process the menu in a switch, setting the threshold as either 10, 20, or 30%. The rest of the program will be the same regardless what was the menu choice.

Incremental development: first do the textbook problem without input validation, then extend with validation, then extend for the additional parts.

View 4 Replies View Related

C# :: Progress Bar Percentage Disappears When Loading

Mar 1, 2014

Why does my progressbar percentage text disapear when progressbar starts loading?? Am I missing out anything?

int percent = (int)(((double)(progressBar1.Value - progressBar1.Minimum) /
(double)(progressBar1.Maximum - progressBar1.Minimum)) * 100);
using (Graphics gr = progressBar1.CreateGraphics()) {
gr.DrawString(percent.ToString() + "%",
SystemFonts.DefaultFont,

[Code] ....

View 1 Replies View Related

C :: User Inputted Validated Grade As Percentage

Jan 2, 2014

I am trying to get this program to accept two inputs Student number and grade and validate them both

However the program skips over the student number

Code attached AssignmentProgram.c

View 1 Replies View Related

C++ :: How To Compare Two Files And Display Their Comparison Percentage

Feb 10, 2013

How to compare two files(two texts documents) and display their similarity percentage by using C++?

View 10 Replies View Related

C# :: Constant Read CPU Percentage And Display It To Textbox?

Feb 18, 2015

What I need to do Is constantly read the cpu percentage and display it to a textbox, but the issue is I am using the windows form not the console so I cant use a while loop. I think my best bet is to use an event, but I am not sure how.

View 6 Replies View Related

C++ :: Looping With Different Values?

Dec 9, 2013

I want to write a loop to check for prime numbers. So I'm going to check only numbers ending with 1,3,7,9.

So I need a loop that will increment with 2,4,2,2 and again 2,4,2,2...

What king of loop is best, a 'for loop' or a 'while' with switches in it or something else?

Basically I need to increment three times with 2 and then with 4, three times with 2 and then with 4...

View 9 Replies View Related

C/C++ :: Infinite Looping For Map?

Jan 13, 2015

I have been trying to get this piece of code to work but it seems to be running infinitely. What i'm trying to do is that whenever the iterator points to the map element, I check whether the element is 1 or 0. If it is 0, *do something*. But if it isn't, it should not do anything and proceed to the next element in the map.

//infinite loop - not working!
for (MapType::iterator p = pwCounter.begin(); p != pwCounter.end(); ++p) {
if (p->second.second != 1) {

[Code]....

View 1 Replies View Related

C++ :: Program Keeps Looping Infinitely

May 21, 2014

Why this program keeps looping infinitely when i run it and try to put some input...

#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
using namespace std;
struct Account {

[Code] ....

View 1 Replies View Related

C++ :: Looping Through Template Objects In Map

Dec 30, 2014

How to get this code working

template <typename T>
class Dummy {
// Implementation
};
template <typename T>
class SomeClass

[Code] ......

View 4 Replies View Related

C++ :: Looping In CPP Class File

Jan 4, 2014

I have a class with a .h and a .cpp file. (I'm unique!) In the .cpp file, I have a loop and a nested loop. It worked fine when it wasn't in a separate file. Now, the loops will not loop and the value found at the end is some random out of the all park number because no looping took place. I am positive that the conditions and variables are set properly.

View 1 Replies View Related

C/C++ :: Cannot Find Out Why A Certain Part Is Looping

Jan 20, 2015

I am having a little bit of trouble with what should be a simple part in my code. For some reason it keeps looping the name part of the program and I seem to be passing over the problem in the code.

Here is the code:

#include <iostream>
#include <string>
using namespace std;

[Code]....

View 6 Replies View Related

C# :: Looping Through A Range Of IP Addresses

Feb 6, 2014

I want to take a starting IP on a local network, and loop through to an ending IP on a local network, pinging all the IP addresses in between. For instance, ping all IP addresses between 192.168.1.1 - 192.168.1.255 (user enters desired starting IP and ending IP in text boxes).

I have the ping functionality working, and i can make it all work with lots of messy string parsing.. but it seems sloppy to me.

I have to split the strings (start and end IP) to get the last octet, then subtract to get the range of IPs. Then loop through, adding 1 to the last octet, and converting back to a string each time.

The C# Ping class can use either a string or an IPaddress for its Send method. If I use IPAddress, I just have to convert it from the text box it originates in, but the adding 1 to the last octet in the loop is a hassle.

Anyway, I guess the only question I have is, if you had to loop through a range of IP addresses, how would YOU do it?

public Job(string ipStartIn, string ipEndIn) {
long ip1 = Convert.ToInt64(ipStartIn);
long ip2 = Convert.ToInt64(ipEndIn);
IPStart = new IPAddress(ip1);
IPEnd = new IPAddress (ip2);
this.deviceAlive = false;

[Code] ....

View 14 Replies View Related

C/C++ :: Looping Recursive Functions?

Feb 10, 2014

how to recursively modify my program. The problem I'm hacing is the the program is not looping correctly and also not printing the correct number. I've calculated the payoff correctly, also I've only been able to print the first section of R3. I can't figure out how to loop it to get R2 to stay at 2 then go to 3 after all possiblities of R2 at 2. Enventually, R1 will change to 2 then 3; 3 being the highest number earned. To be mentioned that will be three recursive function loopR1, loopR2, and loopR3 for each column.

The result of the program should look like:

R1 R2 R3
1 1 1 payoff is 1
1 1 2 .......... 1
1 1 3 .......... 1
1 2 1 .......... 1
1 2 2 .......... 1
...
...
...
3 3 2 .............. 5
this is what I have so far:

#include <stdio.h>
#include <stdlib.h>
int payOff(int r1, int r2, int r3);
void loopR3(int R3, int upto);
void loopR2(int R2, int upto);

[Code].....

View 12 Replies View Related

C/C++ :: Won't Stop Looping If Statement

Jan 22, 2015

My program is designed to take a reading from a glucometer and light an LED if the reading is too high or too low. I used this code:

#include <eHealth.h>
void setup(){
pinMode(13, OUTPUT); //first alert
pinMode(12, OUTPUT); //green LED

[Code]....

The glucometer stores the tests and the code just pulls the most recent one, however even if I unplug the glucometer the first if statement keeps repeating and the LED in pin 12 keeps shining. Is it the if statement itself malfunctioning, or is the Arduino storing the data it pulled and just repeatedly plugging that into the if loop?

View 3 Replies View Related

C++ :: Create A Program Using Nested Looping?

Nov 5, 2013

You are to create a program using nested looping. Your program is to have a menu asking the user to select which pattern to create and how many rows to use (it should accept 1 to 10 rows and keep the aspect ratio of the pattern). The patterns are 1 - Box, 2 - V, 3 - Inverted V. Note, if I select pattern 1 with 10 rows, the box will have 10 asterisks in the first row.

Okay so i came up with the box but i have been getting stuck at getting the V or inverted V.

View 1 Replies View Related

C++ :: While Loop Keeps Looping Without Getting Input From User

Dec 5, 2013

struct stu_dat //outside main function
{
int rollno;
char name[45],
float average;

[Code] ....

No compilation problem.when executing prompt waits for inputting rollno, but, as soon as i enter a char string it keeps looping displaying the "want to enter more data?".i cant understand what is going on,as there is no compilation problem and runs good till i input the name.

View 3 Replies View Related







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