Welcome, Guest

Go Back   TechieHQ - Computer Help Forum · » Software & Internet · HTML & Coding
Reload this Page Need a little help with programming in C#

Need a little help with programming in C#

HTML & Coding HTML, XHTML, CSS, XML and other coding issues you may code into.

Reply
 
Thread Tools Display Modes
  #1  
Old Feb 15th, 07, 11:00 AM
spike228's Avatar
spike228
STS 44
Posts: 2,202
Status: Offline
shield_mod.giftechie.gif
 
From: Honolulu, Hawaii
Joined: Jul 2004
Rep: spike228 is a splendid one to beholdspike228 is a splendid one to beholdspike228 is a splendid one to beholdspike228 is a splendid one to beholdspike228 is a splendid one to beholdspike228 is a splendid one to beholdspike228 is a splendid one to behold
Need a little help with programming in C#

If anyone knows how to program in C#, I have a question.

This is the part of my code in question:
Code:
   /* while loop will keep prompting user inputs EOF  */
            while (flag != EOF)
        {
                /*  user prompt will loop if while statement is true */
                printf("Enter annual interest rate (in decimal): ");
                flag = scanf("%f" ,&annual_interest);

                printf("Calculate compounding years, months or days?\n");
                printf("Enter '1' for years, '2' for months, '3' for days: ");
                flag = scanf("%f", &compound);

        if (compound = 1)
        {        printf("Enter number of years compounding: ");
                flag = scanf("%f" ,&years);
        }

        else if  (compound = 2)
        {       printf("Enter number of months compounding: ");
                flag = scanf("%f", &months);
                        years = months / 12;
        }

        else if (compound = 3)
        {       printf("Enter number of days compounding: ");
                flag = scanf("%f", &days);
                        years = days / 365;
        }
When I enter 1, 2 or 3, for compounding years/months/days, the program is suppose to jump to the next respective user prompt.

But my problem is that the "if" statements seem to be ignored for some reason. I know that the user is assigning "compound" and the "if" statements should be reading "compound" to see which one of the statements are true. But it simply runs as if there were no "if" statements at all.

I tried commenting out the first "if" statement and it prompted me for "months" regardless of what number I assign "compound" as. the same happens if I don't comment out the first "if" statement, in which case it would keep prompting me for "years".

Does anyone know what I am doing wrong?

Thanks!



__________________
Spike
Reply With Quote
Advertisement
  #2  
Old Feb 15th, 07, 11:39 AM
spike228's Avatar
spike228
STS 44
Posts: 2,202
Status: Offline
shield_mod.giftechie.gif
 
From: Honolulu, Hawaii
Joined: Jul 2004
Rep: spike228 is a splendid one to beholdspike228 is a splendid one to beholdspike228 is a splendid one to beholdspike228 is a splendid one to beholdspike228 is a splendid one to beholdspike228 is a splendid one to beholdspike228 is a splendid one to behold
okay nm, it was a totally stupid error that I overlooked.

if anyone is wondering, i used "=" as an equality instead of "==".

"=" is only used for assignments.



__________________
Spike
Reply With Quote
  #3  
Old Feb 15th, 07, 2:17 PM
Cryptoboats's Avatar
Cryptoboats
Ban Stick
Posts: 1,325
Status: Offline
shield_mod.giftechie.gif
 
From: Norfolk, VA
Joined: Jun 2005
Rep: Cryptoboats has much to be proud of his / her geeknessCryptoboats has much to be proud of his / her geeknessCryptoboats has much to be proud of his / her geeknessCryptoboats has much to be proud of his / her geeknessCryptoboats has much to be proud of his / her geeknessCryptoboats has much to be proud of his / her geeknessCryptoboats has much to be proud of his / her geeknessCryptoboats has much to be proud of his / her geeknessCryptoboats has much to be proud of his / her geeknessCryptoboats has much to be proud of his / her geekness
Glad I could help

Actually, I am in the process of learning C, so I was going to whip out my book and see if I could figure it out.



__________________
A wise man can learn more from a foolish question than a fool can learn from a wise answer. ~Bruce Lee
Reply With Quote
  #4  
Old Feb 15th, 07, 2:27 PM
Crimson's Avatar
Crimson
Devil's Advocate
Posts: 469
Status: Offline
techie.gif
 
From: Norfolk, VA
Joined: Aug 2006
Rep: Crimson is a nerd at heartCrimson is a nerd at heartCrimson is a nerd at heartCrimson is a nerd at heart
im_gtalk.gif
I do PERL. Well I try to do PERL.



__________________
"I think there is a world market for maybe five computers."-Thomas Watson, chairman of IBM, 1943.
"There is no reason anyone would want a computer in their home."-Ken Olson, founder of DEC, 1977.
Reply With Quote
Reply

Tags
programming


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Programming computer question Dave601 General Hardware 5 Oct 24th, 04 8:17 PM
Programming Problem Dave601 Windows XP 3 Feb 12th, 04 2:40 AM
What programming languages do you know? xtremegamer HTML & Coding 19 Dec 3rd, 03 2:07 AM


All times are GMT +1. The time now is 6:05 PM.