C++ :: Mortgage Calculator - Displaying Months In Correct Order

Mar 29, 2013

I need my code to display Month but it seems my code is skipping month's and not displaying 1, 2 3. It's going 1 , 3 ,5 and so on. This is the code i have for it

Code:
int month = 1;

And later on the code i have month++ That's my first mistake and i'm not sure how to possibly fix it. My second mistake is my Interest Paid output. This is the code i have for it

Code:
interestPaid = loanBalance*i;

This is on the while loop, but i'm not sure why it's not displaying the correct amount. It should display for month 1 = 500.00 , Month 2 = 498.28 and Month 3 = 496.55 and so on... However my code display's something close to it, but not that. i is my monthly interest rate. My code for it seems to be fine. If i can fix this two things i'll be able to finish the project. This is my entire code, how i can fix it so that my month is displayed in 1, 2, 3, etc.... and not 1, 3, 5, etc... And why my interest is not displaying what my professor has on his output screen (i provided the first three months on top in bold) If i can fix those things i'll have the rest. Here's my entire code

#include <iostream>
#include <iomanip>
using namespace std;
int main ( ) {
int month = 1;
// Holds the user's amount of loan.
double loanAmount;
// Holds the user's interest rate.
double i;

[Code] ....

View 3 Replies


ADVERTISEMENT

C++ :: Displaying Correct Output By Using For Loop (with Pointers)

Feb 4, 2014

I wanted to display the correct output by using a for loop at the end of my code, but for some reason it's not working correctly.

#include <iostream>
using namespace std;
int main() {
int* ipArray[3];
for(int i = 0; i < 3; i++) {
ipArray[i] = new int [5];

[Code] .....

What I wanted to do is pretty much match my 1st out put like 0 1 2 3 4 but my 2nd output only outputs 24's and I don't know why

View 11 Replies View Related

C :: Recursive Function Not Displaying Correct Sequence Request

Jul 1, 2013

Ok, so the assignment is to use a recursive function to display a request for a certain position in the Fibonacci Sequence (0, 1, 1, 2, 3, 5, 8, 13...)

The program I have written works, but it displays the wrong number in sequence. The book says that when you enter "8" you should receive "13", which is correct in the order of the sequence, though my program is producing "21" which is the next number in the sequence.

I tested it with a few more numbers and when I enter "7" it produces "13" and when I enter "6" it produces "8" and so on.

Code:
//Cameron Taylor
#include <stdio.h>
int main(){

[Code].....

View 2 Replies View Related

Visual C++ :: Nim Project - Not Displaying Matches But Display Correct Number

Apr 9, 2013

I am having one issue with my project. We are making a game of Nim code.I'm 99% done with it, i worked hard on it and i feel like i did a good job, however my project is not displaying the matches i want. For example, it display's the inital number of them 23. But once the first player subtracts a number, it doesn't display matches for player 2, just the number of matches remaining. Then as i keep running the program the same thing happens. This is what it's supposed to
output:

"Input/Output sample
WELCOME TO NIM
------- -- ---
Enter the starting player's name (no spaces)-->John
Enter the second player's name (no spaces)-->Mary
There are 23 matches.
ooooooooooooooooooooooo
|||||||||||||||||||||||
Player John please enter the number of matches to remove-->2
There are 21 matches.
ooooooooooooooooooooo
|||||||||||||||||||||
Player Mary please enter the number of matches to remove-->3
There are 18 matches.
oooooooooooooooooo
||||||||||||||||||
Player John please enter the number of matches to remove-->1 "

This is entire code.

#include <iostream>
#include <string>
using namespace std;
int main() {
// Holds variables.

[Code] ....

I will attach my code as well.ProjectNim.cpp

View 7 Replies View Related

C/C++ :: Using Semaphores On Critical Region - Processes Not In Correct Order

Mar 2, 2014

I'm trying to use semaphores on three different processes so that each process won't enter the critical region at the same time and also go in the order: process 1 -> process 2 -> process 3. However, everytime i run the code the process 3 keeps going before process 2.

Here's my code:

#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>

[Code].....

the processes should print out like this:

process 1: 100000
process 2: 300000
process 3: 600000

View 1 Replies View Related

C++ :: Convert A String Into Mathematical Calculation And Calculate In Correct Order

May 6, 2013

I want to program an advanced calculator. I'd like to enter some more complex expressions like -17+3*4*(4-sqrt(4) and i want, that mathematical operations are done the correct order, so at first 4-sqrt(4) is calculated, then 3*4*2 and then -17 is subtracted.

Problem 1: Convert a string into a mathematical calculation
Problem 2: Calculate in the correct order

How would I do that (I dont expect perfecly precoded calculators from you, just the way how to do it)

Google search just delivers primitive calculations with entry methods like

Enter first number 1
Enter operator +
Enter second number 2

3

But thats not what i want

View 2 Replies View Related

C/C++ :: How To Incorporate Exception Handling Code Into Calculate Mortgage Program

Dec 15, 2014

How to incorporate exception handling code into my existing calcMortgage code. While I was researching exception handling, I thought "what would happen with my current code if someone input the principal with a comma in it?". Typically people write two hundred thousand like so.... 200,000. While experimenting with my original code, I remembered reading in my research that someone had done their calcMortgage with the output prompt "DO NOT USE COMMAS". So, when checking to see if my code would run, I did not use commas.

Well, guess what...using a comma in the principal causes an error with a negative numerical output. lol PERFECT!!!! Obviously, the easy thing to do would be to put output instructions in the code telling the user NOT to use commas, but the assignment requires me to use exception handling. The code itself works, but the calculation produces a negative monthly payment.

How would I insert exception handling code into my current code to correct this problem??

#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
struct calcMortgage {
double Principal, numYears, IntRate, monthlyPayments;};
int main(){

[Code]...

would I use a try or a throw??

View 14 Replies View Related

C/C++ :: Simulator To Implement Populations For Given Number Of Months?

May 18, 2013

How can i implement a simulator that computes the populations for a given number of months for all sectors.

View 1 Replies View Related

C++ :: Print Out Which Months Have Lowest And Highest Amount Of Rainfall

May 5, 2014

I have to print out which months have the lowest and highest amount of rainfall. I know how to find the lowest and highest value but how do I match them with there month?

#include <iostream>
using namespace std;
int main() {
const int rainfall = 12;
double months[rainfall];
int count;

[Code] .....

View 2 Replies View Related

C++ :: Calculate User Birthday In Months / Days / Hours And Minutes From Today Date

Jul 24, 2014

The problem is that I need to figure out the user's birthday in months, days, hours, and minutes from today's date.

Here's what I have so far.

#include<iostream>
#include<cmath>
#include<ctime>
using namespace std;
int main() {
int todayDay, todayMonth, todayYear;
int birthDay, birthMonth, birthYear;

[Code] ....

I haven't initialized all the variables, yet. And it's very unfinished. I need to figure out how to convert years from the age into months only. And I need to figure out how to calculate the hours, seconds, and minutes.

View 3 Replies View Related

C++ :: Get Correct Answer For Every Value Of X / N And A

Jun 10, 2014

I am expecting to get correct answer for every value of x, n and a[i] where

-10^9 <= a[i] <= 10^9
1 <= x <= 10^18
and 1 <= n <= 10000

Every value here is an integer value

#include<cstdio>
#include<iostream>
#include<cmath>
#include <float.h>

#define sBig long long int

[Code] .....

View 1 Replies View Related

C++ :: How To Correct The Search In The End Of Program

Jun 1, 2013

Code:
#include<conio.h>#include<iostream.h>
class air_line {
private:
char name[5][100],name1;
long double opt,opt1,opt2,cnic[5],ticket_number[5],ticket_number1,cnic1;
public:
void input()

[code].....

View 1 Replies View Related

C :: Correct Answer Does Not End Game

Feb 21, 2013

Okay so I thought I had this assignment completed properly last week. Last night I found a bug while playing the game.why won't the game end when the player guesses the correct number? The game allows you to finish using the max number of guesses even though you already guessed the correct number.

Code:

#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#define MAXGUESSES 6
#define MAXGAMES 20
#define MAXNUMBER 100
}

[code]....

View 9 Replies View Related

C :: What Is Correct Way To Print A Float

Feb 17, 2013

I have a program that printf a float that is returned by a function like this:

Code:

printf("%3.1f
", myfloat());
...
float myfloat(void) {
code....
}

In w32 my program has been running ok, but when run in a w64, it crash at the printf. If I change the definition of the function to return double it runs ok. in printf format string - Wikipedia, the free encyclopedia , in the "type" section I see there is no definition to print a float, but %f is for double in fixed point.So the question is what is the correct way to printf a float? must I cast? or is it better to return double? if so, does it have a performance penalty?

View 4 Replies View Related

C++ :: Operator Overloading In A Correct Way?

Apr 1, 2013

Well... I observed, as a non-professional programmer that "overloading operators" has some strict rules and some conventions... so any operator can differ from another. In order to have a clearest idea, I'd like to ask you to specify, for every operator, the correct (or best) way to overload it.

There are cases where you define &operator and cases where you define operator (without "&"). There are cases where operator are defined as "friend" inside class, and other cases where operator is declared externally.

example: ostream &operator<<
(why it uses & ??)

So can we have a summary for all kind of operators?

View 19 Replies View Related

C/C++ :: Put 2 Marks For Each Question Correct?

Jun 13, 2014

#include <iostream>
#include <string>
using namespace std;
void secondq();
void thirdq();

[Code]....

View 2 Replies View Related

C++ :: Getting Correct Numbers After Sorting

May 10, 2014

I'm trying to make a number sorting program with other features, but the numbers are all wrong.

#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
void readData(int list[], int size);
int main() {
int size = 50;
int scores[50] = {0};

[Code] ....

Input.DAT

376 389 450 735 600 576 612 700 450 628 778 389 667 500 475 550 687 791 829 344
549 476 400 587 535 657 789 583 340 764 422 826 566 436 565 834 533 423 837 701
847 521 746 356 582 465 493 593 425 421

View 2 Replies View Related

C++ :: Giving Score To Correct Player

Jul 22, 2013

I have programmed a game where you guess a number (1-6) and if the number is equal to the random number then give the player score + 10. But if I have selected for example 4 players then if the game will give player 1 a score it gives player 2 a score instead? What can be causing this error?

Code:
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int cube;
int number[4];

[Code] .....

View 6 Replies View Related

C :: How To Call Function With Correct Arguments

Sep 13, 2013

I'm not a programmer, at least, not a good one. I'm a researcher and I need to implement this function and test it and use it for my research. I tested some clustering methods in JAVA and Matlab and also I want to test it on C. I don't know too much about programming, especially about C, I know nothing. I tried to implement some basic methods but I failed.

It's all about K-Means Algorithm. I'm working on a disease and I'm trying to find ways to early diagnosis. Anyway, these are details. The thing is, I found a 'free to use' function but I don't know how can I use it. I tried to learn something from Net, I downloaded a compiler, I paste the code and I get many errors... And I heard that I have to do some "calling function" stuff but I don't know how to..

The code is in the link below: URL....It's not imperative that using this function, it can be another one but it had to written in C.

View 13 Replies View Related

C :: File Could Not Be Opened While Filename Seems Correct

Feb 10, 2013

I'm new to C and encountered a weird problem. Here's the code:

int main(){
char name[]="";
readname(name) ;
printf("The filename is: %s
",name);
printf(name);

[Code] ....

I compile this with no problem, but gives "File could not be opened". the strcmp tells me name and "snazzyjazz.txt" are not equal. but when I print them I get the same output.

View 2 Replies View Related

C++ :: Output Correct Standard Deviation

Feb 1, 2015

The program does compile the average and the mean correctly. I can't understand why the standard_deviation member function isn't applying the sqrt properly:

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
const int N = 10;
class Standard_Deviation {

[Code] ....

View 7 Replies View Related

C/C++ :: Output Is Not Correct - Squaring Input?

Feb 6, 2015

Ok so This is what the output of the program should be.

enter the count of input integers: 1
The count of the integers must be two or more. Please enter a valid number : 3
Enter integer #1 : 2
Enter integer #2 : -1
Enter integer #3:5

The positive numbers entered and their squares are:

2 4
5 25

My Code :

//header files
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<math.h>

[Code].....

View 6 Replies View Related

C/C++ :: For Loop Not Producing Correct Output

Nov 14, 2014

Something is wrong with option 1. For some reason it adds 1, 2, 3, 4 ... 5 onto the output and I can't think why. Here is a screenshot.

Also how can I make the output a little neater? I tried to use but it just looks horrible.

I had linked the source code! Why is there no edit button?!

#include<iostream>
using namespace std;
int main(){
int option;
cout << "Welcome to my program. Please select a following option.

[Code] .....

View 3 Replies View Related

C++ :: Write A Calculator Using Two Stacks

Apr 13, 2014

I just started by defining a stack class (stackDouble). I need to write a program that accepts an infix calculator expression, with the following operators (**, exponentiation, /, division, and, -, subtraction. The operator precedence is exponent, division, and subtraction.I need to use a stack of doubles and a stack of strings, of which I can write two classes, or write a single stack template. The user will input the expression just via cin, and there will be a # before every number, a ! before each operator, and a . at the end of the expression. '#', '!', or '.' can be input into a char variable, numbers into a double variable and operators into a string variable.

For example, the following would output 6:

# 3 ! / # 2 ! / # .5 ! ** # 2 .

As stated above, I already made up a stackDouble class. What would I need to do to create the other class (I don't think I want to do it with a template)?

Code:
#include <iostream>
#include <string>
using namespace std;
class stackDouble{

[code]....

View 2 Replies View Related

C :: BMI Calculator With Added Function

Aug 17, 2013

getting error with gcc under OSX.

Code:

/* bmi2.c */
#include <stdio.h>
main()
{
float height, weight;

printf("Enter weight:
");

[code]....

View 2 Replies View Related

C :: Calculator Using Mouse With A Bug While Dragging

Mar 6, 2015

I have an assignment to do a calculator in C, wich will work by clicking the numbers with the mouse, however i have a bug that when i hold the mouse and dragg it, it assumes that I'm clicking multiple times, also, when I click in an empty space the program creates a blank space on the calculator screen.

Code:

#include <stdio.h>
#include <conio.h>
#include <math.h>
#include "..MouseHandler.h" // ajustar o caminho ao seu projecto
#include "..calcSkinLib.h" // ajustar o caminho ao seu projecto
#define PI = 3.1415;

[code]....

View 2 Replies View Related







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