Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 18th, 2006, 5:29 AM   #1
DC_FC79
Newbie
 
Join Date: Nov 2006
Posts: 8
Rep Power: 0 DC_FC79 is on a distinguished road
New to the forum, need a bit of help/guidance re C#

I have to write a program using C# for an assignment,

basically the program must work out the amount tat each person should pay towards a tea kitty each week. Each person drinks drinks drinks a day. 1 pint of milk makes 1 drinks, the teabags come in boxes of 480 teabags(1 teabag makes 1 drink) and the bag of sugar is used to make 100 drinks.

i obviously declare the variables at the start i got that bit but its the rest of the program

I just dont know where to start(im not askin for someone to do it for me but for some pointers),

Id appreciate your help alot,

Last edited by DC_FC79; Nov 18th, 2006 at 5:41 AM.
DC_FC79 is offline   Reply With Quote
Old Nov 18th, 2006, 5:43 AM   #2
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Well, it's simple arithmetic, no? Write down the equations you'd use to calculate it manually, and then convert them into C# code.
Arevos is offline   Reply With Quote
Old Nov 18th, 2006, 5:46 AM   #3
DC_FC79
Newbie
 
Join Date: Nov 2006
Posts: 8
Rep Power: 0 DC_FC79 is on a distinguished road
ok so i do the calculations but its how to write it into the program, what lines of code to use

are there any sites i can have a look at for a quick tutorial on C#
DC_FC79 is offline   Reply With Quote
Old Nov 18th, 2006, 5:55 AM   #4
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4 Polyphemus_ is on a distinguished road
Use Google.

I think it's rather weird that you have to write a program for an assignment, and you don't even know how to do simple arithmetics.
Polyphemus_ is offline   Reply With Quote
Old Nov 18th, 2006, 6:10 AM   #5
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Well, I'll give you an example similar to your problem. Lets say you want to create a program that converts Fahrenheit into degrees Celsius. It might look something like this:
c# Syntax (Toggle Plain Text)
  1. using System;
  2.  
  3. namespace Example
  4. {
  5. class FahrenheitCelsiusConverter
  6. {
  7. static void Main(string[] args)
  8. {
  9. // Get input from the user
  10. Console.WriteLine("Enter a temperature in Fahrenheit");
  11. string userInput = Console.ReadLine();
  12.  
  13. // Convert user input into a number
  14. double fahrenheit;
  15. try
  16. {
  17. fahrenheit = double.Parse(userInput);
  18. }
  19. // If the user entered something that wasn't a number
  20. // then complain and exit
  21. catch (FormatException)
  22. {
  23. Console.WriteLine("Invalid input. Exiting!");
  24. return;
  25. }
  26.  
  27. // Convert fahrenheit to celsius using an equation
  28. double celsius = (fahrenheit - 32) / 1.8;
  29.  
  30. Console.WriteLine("The temperature in Celsius is " + celsius);
  31. }
  32. }
  33. }
Note that "double" is a type of number in C# that can have decimal places. If you only need whole numbers (i.e. integers), then you can use "int" instead.
Arevos is offline   Reply With Quote
Old Nov 18th, 2006, 7:02 AM   #6
DC_FC79
Newbie
 
Join Date: Nov 2006
Posts: 8
Rep Power: 0 DC_FC79 is on a distinguished road
Quote:
Originally Posted by Polyphemus_ View Post
Use Google.

I think it's rather weird that you have to write a program for an assignment, and you don't even know how to do simple arithmetics.
i can do the arithmetics no problem, the fact is that all this C# has gone over my head,
DC_FC79 is offline   Reply With Quote
Old Nov 18th, 2006, 7:07 AM   #7
DC_FC79
Newbie
 
Join Date: Nov 2006
Posts: 8
Rep Power: 0 DC_FC79 is on a distinguished road
Quote:
Originally Posted by Arevos View Post
Well, I'll give you an example similar to your problem. Lets say you want to create a program that converts Fahrenheit into degrees Celsius. It might look something like this:
c# Syntax (Toggle Plain Text)
  1. using System;
  2.  
  3. namespace Example
  4. {
  5. class FahrenheitCelsiusConverter
  6. {
  7. static void Main(string[] args)
  8. {
  9. // Get input from the user
  10. Console.WriteLine("Enter a temperature in Fahrenheit");
  11. string userInput = Console.ReadLine();
  12.  
  13. // Convert user input into a number
  14. double fahrenheit;
  15. try
  16. {
  17. fahrenheit = double.Parse(userInput);
  18. }
  19. // If the user entered something that wasn't a number
  20. // then complain and exit
  21. catch (FormatException)
  22. {
  23. Console.WriteLine("Invalid input. Exiting!");
  24. return;
  25. }
  26.  
  27. // Convert fahrenheit to celsius using an equation
  28. double celsius = (fahrenheit - 32) / 1.8;
  29.  
  30. Console.WriteLine("The temperature in Celsius is " + celsius);
  31. }
  32. }
  33. }
Note that "double" is a type of number in C# that can have decimal places. If you only need whole numbers (i.e. integers), then you can use "int" instead.
Arevos

ill have a go at changing the bits necessary for me
DC_FC79 is offline   Reply With Quote
Old Nov 18th, 2006, 7:25 AM   #8
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by DC_FC79 View Post
ill have a go at changing the bits necessary for me
Er... I'd have preferred it if you had said something more like, "That's helped me understand how C# works," rather than, "I'll copy the structure of your code without necessarily understanding how it works."
Arevos is offline   Reply With Quote
Old Nov 18th, 2006, 10:19 AM   #9
Samuaijack
Programmer
 
Samuaijack's Avatar
 
Join Date: Jul 2006
Location: using Earth.Africa.Egypt.Cairo;
Posts: 76
Rep Power: 3 Samuaijack is on a distinguished road
Have you ever write any thing in C# before ????
Samuaijack is offline   Reply With Quote
Old Nov 18th, 2006, 12:26 PM   #10
crawforddavid2006
Expert Programmer
 
crawforddavid2006's Avatar
 
Join Date: Apr 2005
Location: Not sure yet
Posts: 582
Rep Power: 0 crawforddavid2006 is an unknown quantity at this point
Send a message via AIM to crawforddavid2006 Send a message via MSN to crawforddavid2006
Quote:
Originally Posted by Arevos View Post
Well, I'll give you an example similar to your problem. Lets say you want to create a program that converts Fahrenheit into degrees Celsius. It might look something like this:
c# Syntax (Toggle Plain Text)
  1. using System;
  2.  
  3. namespace Example
  4. {
  5. class FahrenheitCelsiusConverter
  6. {
  7. static void Main(string[] args)
  8. {
  9. // Get input from the user
  10. Console.WriteLine("Enter a temperature in Fahrenheit");
  11. string userInput = Console.ReadLine();
  12.  
  13. // Convert user input into a number
  14. double fahrenheit;
  15. try
  16. {
  17. fahrenheit = double.Parse(userInput);
  18. }
  19. // If the user entered something that wasn't a number
  20. // then complain and exit
  21. catch (FormatException)
  22. {
  23. Console.WriteLine("Invalid input. Exiting!");
  24. return;
  25. }
  26.  
  27. // Convert fahrenheit to celsius using an equation
  28. double celsius = (fahrenheit - 32) / 1.8;
  29.  
  30. Console.WriteLine("The temperature in Celsius is " + celsius);
  31. }
  32. }
  33. }
Note that "double" is a type of number in C# that can have decimal places. If you only need whole numbers (i.e. integers), then you can use "int" instead.
Hey we don't do homework unless they have shown an obvious effort towards the assignment.
__________________
Quote:
Originally Posted by DaWei View Post
Well, it's better than Pen Islands url....;)

crawforddavid2006 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

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
Introduction forum, Moved big_k105 Community Announcements and Feedback 12 Nov 3rd, 2005 10:06 AM
PHP forum script grimpirate PHP 32 Sep 19th, 2005 11:08 PM
Forum FAQs?? DaWei Community Announcements and Feedback 8 Sep 3rd, 2005 1:47 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:34 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC