Click here to Skip to main content
15,919,028 members
Home / Discussions / C#
   

C#

 
AnswerRe: C#.Net application Pin
Colin Angus Mackay27-May-06 9:47
Colin Angus Mackay27-May-06 9:47 
GeneralRe: C#.Net application Pin
betty_boop27-May-06 10:04
betty_boop27-May-06 10:04 
GeneralRe: C#.Net application Pin
Colin Angus Mackay27-May-06 10:24
Colin Angus Mackay27-May-06 10:24 
GeneralRe: C#.Net application Pin
betty_boop27-May-06 10:36
betty_boop27-May-06 10:36 
GeneralRe: C#.Net application Pin
Ravi Bhavnani27-May-06 10:42
professionalRavi Bhavnani27-May-06 10:42 
GeneralRe: C#.Net application Pin
Colin Angus Mackay27-May-06 10:46
Colin Angus Mackay27-May-06 10:46 
GeneralRe: C#.Net application Pin
betty_boop27-May-06 11:21
betty_boop27-May-06 11:21 
GeneralRe: C#.Net application Pin
Colin Angus Mackay27-May-06 13:41
Colin Angus Mackay27-May-06 13:41 
betty_boop wrote:
I have never been so frustrated in my life!!!!!


Yeah! But it is such a wonderful feeling when it all works out!

Okay - The code you have probably doesn't even compile. Code can only exist within methods (and Properties - but I'm guessing you haven't got that far yet)

First, you are thinking about the whole thing sequentially (which is common for a beginner). Think about calling method like looking up an entry in the dictionary or an encyclopaedia (The methods themselves are like the entry in the book). You don't read a encyclopaedia from start to finish. You jump in where you need to. You might want to read an article about Edinburgh, and it mentiones a famous ex-resident, Sean Connery, and you want to know more so you skip to that entry, and it mentiones James Bond movies so you jump to that entry. The editor that compiles the encyclopaedia isn't going to know what order you want to read in so cannot compile the book in the order Edinburgh, Sean Connery, James Bond. The only sequential things is the normal reading order of the sentences and paragraphs within an entry. In a program the developer doesn't know what order the methods will be called in (typically - your examples are simple enough that you can tell in advance, but when you get to interactive stuff it all depends on the user making descisions at runtime)

Next thing is that a method knows nothing about anything before it was called unless you tell it (by passing in parameters, or if the information is available by calling other methods, from class fields or properties - don't worry about all that just now, at this stage I think concentration on passing in parameters is what your professor is interested in)

Going back to your original description of the problem:
betty_boop wrote:
I have to design a solution with a Main() method that holds an integer variable named seconds to which I assign a value, create a method to which you pass the value, the method displays the seconds in minutes and seconds (66 sec. = 1 min and 6 sec.)...I go there from hours and so on,


That means the Main method needs very little
// holds an integer variable named seconds to which I assign a value
int seconds = 66;
 
// create a method to which you pass the value
DisplayTime(seconds);

That is all that your Main() method needs.

The more complext thing is creating the DisplayTime() method.
You have a loop which you don't need. Some of the maths may feel a little odd to start with but you'll begin to recognise common patterns soon enough. The trick is to think ahead a little and figure out what you are going to need and see if you can get that a better way - Don't worry, this will start to come naturally once you are practiced more. Which is, of course, the purpose of the exercises you are being set.

There are 3600 seconds in an hour.
hours = seconds / 3600; // Remember this is an integer division so 
                        // everything after the decimal point will be truncated.


There are 60 seconds in a minute, but we also need to discount the hours from the total number of seconds.
remainingSeconds = seconds - (hours * 3600); // Remove the number of whole
                                             // hours to get the remaining seconds


The calculation for the minutes is now similar to the hours, but divide by 60. Then the calcualtion for the remainingSeconds is similar to the one above also, but multiplying your calculated minutes by 60.

So you now have hours, minutes and remainingSeconds which you can output using Console.WriteLine();

So, hopefully I've given you enough that you can re-write your code so that it gets you closer to your goal.


"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)

My: Website | Blog
GeneralRe: C#.Net application Pin
betty_boop28-May-06 9:14
betty_boop28-May-06 9:14 
Questionget whether a checkbox is checked or not ASP.net Pin
DeepToot27-May-06 7:36
DeepToot27-May-06 7:36 
AnswerRe: get whether a checkbox is checked or not ASP.net Pin
maryamf27-May-06 11:33
maryamf27-May-06 11:33 
GeneralRe: get whether a checkbox is checked or not ASP.net Pin
DeepToot27-May-06 12:59
DeepToot27-May-06 12:59 
GeneralRe: get whether a checkbox is checked or not ASP.net Pin
leppie27-May-06 18:32
leppie27-May-06 18:32 
GeneralRe: get whether a checkbox is checked or not ASP.net Pin
DeepToot28-May-06 15:41
DeepToot28-May-06 15:41 
Questiontextbox cursor disable Pin
jackalfb27-May-06 6:20
jackalfb27-May-06 6:20 
AnswerRe: textbox cursor disable Pin
Guffa27-May-06 6:49
Guffa27-May-06 6:49 
GeneralRe: textbox cursor disable Pin
jackalfb27-May-06 9:27
jackalfb27-May-06 9:27 
AnswerRe: textbox cursor disable Pin
Guffa27-May-06 22:50
Guffa27-May-06 22:50 
QuestionDBNull and Uniqe ID Pin
NaNg1524127-May-06 5:42
NaNg1524127-May-06 5:42 
Questionusing the scalar execute mode in ado.net 2.0. help!!! Pin
aenon27-May-06 5:41
aenon27-May-06 5:41 
QuestionRegular Expression Control Pin
NaNg1524127-May-06 4:56
NaNg1524127-May-06 4:56 
AnswerRe: Regular Expression Control Pin
Guffa27-May-06 5:14
Guffa27-May-06 5:14 
QuestionRe: Regular Expression Control Pin
NaNg1524127-May-06 5:35
NaNg1524127-May-06 5:35 
GeneralRe: Regular Expression Control Pin
Guffa27-May-06 7:16
Guffa27-May-06 7:16 
GeneralRe: Regular Expression Control Pin
NaNg1524127-May-06 7:28
NaNg1524127-May-06 7:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.