C :: Donate Or Invest Into The Fund - Iterations Of A Loop
Sep 20, 2013
Basically I have to write a program where there is a fund and the user sees a display menu
1- Donate to the fund
2- Invest in the Fund
3- Check Fund Balance
4- Quit
And the user can either donate or invest into the fund and its a loop. I have the loop written and working I just can't seem to figure out how to state how many donations or investments were made before the user selected to quit.
I need a final printstatement to say
The final Funds are $______ and there were __ Donations and ___ investments
How to go about counting the iterations and printing it for the user to see.
View 2 Replies
ADVERTISEMENT
Nov 17, 2014
I have to do this assignment but really don't understand the calling and called functions yet. Rewrite your program for computing the value of a sinking fund so that there is a C++ function that is called to calculate the value, i.e., a function that returns the accumulated value based on the number of years with the annual interest rate compounded monthly and a fixed-size monthly deposit.
My program is:
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double R, r, t;
[code].....
View 1 Replies
View Related
Mar 18, 2013
I have this:
Code:
for (chr_min = 0; chr_min <= 24; chr_min += 3) {
strOut = "";
for (ctr_row = 1; ctr_row <=3; ctr_row++) {
switch (ctr_row) {
case 1:
strOut = strOut + Line1.substr(chr_min, 3);
[Code] ....
it is outputting to the shell window, this:
Code:
1
1
1
2
2
3
and that pattern apparently repeats for every iteration that's specified in the outer loop. am I missing something here?
View 14 Replies
View Related
Oct 13, 2014
We are making a program--but every time we input a value for scanf, the following for loop does not work and the program quits without displaying the for loop's function. We are not getting any errors.
View 11 Replies
View Related
Feb 15, 2015
I have tried to submit this topic before but i didn't submit my whole code and it was removed. So here it is. All I am trying to do is load form2 from form1 then back to form1 from form2 for a certain number of times the get out of the loop. I am new to C-Sharp and it seems as though I cant seem to figure out a way to do this.
Here is form1 and form2 code. I have commented out a few things I have tried.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
[Code]....
View 3 Replies
View Related
Jul 1, 2013
Code:
#include <stdio.h>
#include<ctype.h>
void try5t(){
char choice;
int choiceint;
[Code] .....
Loop is repeated an additional time as shown in the screenshot:
View 9 Replies
View Related
Feb 20, 2014
Given a for loop:
int i;
for(i = 0; i < 1000; i++)
;
How many nanoseconds, or microseconds or milliseconds does it take for each iteration? And why do some use it as a timer mechanism?
View 3 Replies
View Related
Apr 19, 2014
I already made a nested for loop into a while loop (below this) and now I'm trying to make the outer for loop into a do while loop, but it's not working.
#include <iostream>
using namespace std;
int main () {
int len;
int j;
int i;
[Code]....
And I can't make this code do the same thing. It stops after one loop, instead of continuing to the end. Why won't the loops continue?
#include <iostream>
using namespace std;
int main(){
int len;
cout << "Enter a number: ";
[Code] ....
View 2 Replies
View Related
Mar 25, 2012
I need to convert the following while loop:
count = 1;
while (caloriesForItem != 0, count != numberOfItems )
{
cout<<"Enter the calories: ";
cin >> caloriesForItem;
totalCalories += caloriesForItem;
count++;
}
This is what I have come up with:
totalCalories += caloriesForItem;
for (count = 1; caloriesForItem != 0; count != numberOfItems)
{
cout<<"Enter the calories: ";
cin >> caloriesForItem;
count++;
cout << "Total calories eaten today = " << totalCalories << endl;
}
However the output is not the same?
View 6 Replies
View Related
Sep 25, 2014
I for the life of me can't get my logic straight. I have 2 lists, 1 a list of text, and the other a list of int.
Here's my main list: List<string> ListNeedToADD = ListOfSPSExt.Except(ListOfReportExt).ToList();
Here's my second list:IEnumerable<int> result2 = Enumerable.Range(1, Convert.ToInt32(myValue)).Except(hostList);
I need to loop through my main list, ListNeedToADD, and for each item in that list, grab 1 value from the 2nd list and send those 2 items to a method. Something like this:
foreach (string myString in ListNeedToADD)
{
foreach (var item in result2)
{
intSort = item;
insertReportLimits(attribTable, myString, intSort, con);
}
}
The problem with doing it the way I am above is it loops through ALL the items for each myString.
For my method, it needs to look like this: insertReportLimits(attribTable, "34257", 22, con); then it would move on to the next: insertReportLimits(attribTable, "34854", 27, con); etc etc.
View 4 Replies
View Related
Feb 22, 2015
I can't get out of my loop to fill the array. This array should stop and print after 10 inputs. but it keeps asking for input.
This is what my code is supposed to do. Use 0 as sentinel for an array. Only positive ints will be entered into the array. A negative int should result in an error message, then input will continue. The numbers will be inserted into the array in ascending order. Do not insert them then sort the array.
#include <iostream>
#include <cmath>
using namespace std;
const int arraySize =10;
[Code].....
View 4 Replies
View Related
Apr 16, 2013
I am using a for loop to count down from 10 to 0 it's working to count down from 10 to 1 but when the program cames to the 0 then the program freezes by any reason.
Code:
#include <iostream>
using namespace std;
int main()
{
int number[2];
cout << "Enter number: ";
cin >> number[0];
if (number[0] == 1)
[Code] ....
View 11 Replies
View Related
Nov 8, 2013
Is there a way to end a loop ?
Code:
while ( menuopt == 1)
{
printf("Lets start
");
printf("12 x 4 = ?
");
[Code] ....
View 2 Replies
View Related
Mar 1, 2013
What I need to do to get rid of the infinite loop?
Code:
do {
printf("Enter the number of tests:");
scanf("%d", &test);
if (test< 0 || test> 4)
printf("Wrong number. Please try again!
");
}
while (test< 0 || test>4);
View 9 Replies
View Related
Apr 17, 2014
So I have a programming assignment.
Code:
#include <stdio.h>
int main(void)
{
int input;
int sum;
int i;
int t;
[Code] .....
So you input an integer ex) 30
the printing of t =(i+i)+1 and i++ is carried out until i=30, which is when the sum of all the t's is printed.
If the value you entered is not an integer, the loop ends.
I'm supposed to do this with one while loop, and no more. I can't use the for loop either.
How can I do this?
View 7 Replies
View Related
Jul 21, 2013
is it possible to output like this using only one loop? if yes, how?
target output Code: ABCDE
EDCBA here is my code but using one loop im not getting my target output Code: #include <stdio.h>
main()
{
int x, y;
for(x='a', y='e'; x<='e'; x++, y--)
{
printf("%c
%c", x, y);
}
getch();
}
View 6 Replies
View Related
Nov 16, 2013
I have a while loop that will not disengage when the input given as "exit".
Code:
while (orders != "exit"){
for (i=0;i<25;i++){
for (j = 0; j<50;j++){
if (i == x && y == j){
printf("H");}
else {
printf("%c", map[i][j]);}
[Code]....
View 1 Replies
View Related
Dec 6, 2013
I'm trying to create a connect four game, but I've ran into a problem while trying to read valid user input.
Code:
// 4 in a row game
#include <stdio.h>
#include <stdlib.h>
#define NUM_ROWS 6
#define NUM_COLS 7
}
[code]...
If the user enters an invalid number, then it works fine, but if a character is entered, the while loop in main never breaks.
View 9 Replies
View Related
Feb 6, 2013
I'm writing a program to sum up the even numbers in between 1 and 100, using a while loop. At the beginning of my program, I initialize a variable "sum" to 0, and a variable "temp" to 1. Afterwards I enter a loop where I determine if "temp" is even or not, and if so add it to sum. However, at the end of my program, when I print "sum", I get a result of 0. Below is my code.
Code:
#include <stdio.h>
int main(void)
{
int sum = 0, temp = 1;
}
[code]...
View 4 Replies
View Related
Nov 24, 2013
Why my if statement for argc <3 will not execute? as the one for argc >3 does...
Code:
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]){
int i;
int fnlength = strlen(argv[2]);
char *namein = argv[2];
int j = (fnlength-1);
char input[100000];
}
[code]....
View 2 Replies
View Related
Feb 19, 2015
While trying to redo everything in c i have an error on a do while loop and i don't understand i've corrected everything else but i don't understand why the error occurs even though it says how to fix it it says error expected ) before token -line 18 part of code
Code:
int main(){
Beep (523,1000); // sound at 523 hertz for 1 000 milliseconds
char cPresent;
do
}
[code]....
this is just extra bits i've added on to the assignment but I've worked on the c++ code for a week now i have less than a day to redo it
View 2 Replies
View Related
May 11, 2013
This is an example from C++ Primer on while loops shortened for simplicity:
int main() {
int value = 0;
while(cin >> value) cout << value;
return 0;
}
When I compile and run the above code the program keeps asking for input after I input nothing but pressing ENTER no matter how many times. The only way I can get it to stop asking for input is to input something other than an int such as a char or string. Program executes as intended after that. I have googled this issue and read all seemingly relevant results and nothing seems to pertain to my exact problem. I think it may have something to do with my computer's own settings or something and am baffled as to what it may be.
View 10 Replies
View Related
Mar 2, 2014
I need to write a complete program using "While Loop" to calculate 1! to 12! using just "int" variables. Only from 1 to 12 and there are no other inputs.. This is my first time using While loop.
View 2 Replies
View Related
Feb 20, 2013
Write a C++ program that uses a while loop to guess a persons age, ask the user if the want to try again if no end the loop. Of course if they guess it the loop also ends
View 3 Replies
View Related
Mar 23, 2014
I am writing a program to tell how long it will take for a loan to be paid off supposing the desired loan is 100,000, the annual percentage rate is 6, and the monthly payment is 1,000. What happens is after I run the program, I get the output of "-24.60" after the last month is paid off. I'm trying to get it to where the last monthly payment is only enough to make the loan 0. Then I want the program to end.
#include <iostream>
#include <iomanip>
using namespace std;
[Code]....
View 4 Replies
View Related
Sep 3, 2014
I am working on a program that is supposed to do I/O file streaming. I dont know if I can properly explain how its supposed to work but I have found the error on my code, I just dont know WHY the error is happening? If you look in the while loop, count changes values like it should, but MOVE and TIP doesnt. Count starts at value 2. So move is 108. Then count becomes 4, but move stays at 108?
tring rec;
fstream myfile("File.txt", ios::in | ios::out);
myfile.seekg(myfile.tellg(), ios::beg);
myfile.seekp(51, ios::beg);
[Code]....
The lines of code im getting errors on is
int move = count * 54;
int tip = move + 51;
Move wont change its value? It stays 108, causing this infinite while loop. Where is the error in my code to cause move to not change values like count does?
I seem to be struggling with I/O File streaming :(
View 2 Replies
View Related