Hello, this is my 1st time posting here. I'm enrolled in a CIS course through devry. This is my assignment: Design a C# solution with a Main ( ) method that holds an integer variable named seconds to which you will assign a value. Create a method to which you pass this value. The method displays the seconds in minutes and seconds. As an example 66 seconds is 1 minute and 6 seconds.
Add a second method to the solution. This method displays a passed argument as hours, minutes and seconds. For example 3666 seconds is 1 hour, 1 minute and 6 seconds.
Add a statement to the Main ( ) method so that after it calls the methods to convert seconds to minutes and seconds, it passes the same value to the new method to convert it to hours, minutes and seconds
I'm getting an error in the Sub method stating that an identifier is expected. This is what i've coded so far: -
using System;
-
public class convertingSeconds
-
{
-
public static void Main()
-
{
-
string secondsString;
-
int minutes, seconds, hours;
-
Console.Write("Please enter the ammount of seconds you would like calculated");
-
secondsString = Console.ReadLine();
-
seconds = Convert.ToInt32(secondsString);
-
hours = Seconds / 3600;
-
minutes = Seconds / 60;
-
minutes = minutes % hours;
-
using (TimeSpan = t)
-
seconds = t.seconds;
-
minutes = t.minutes;
-
hours = t.hours;
-
secondsString = t.secondsString;
-
Sub(t);
-
}
-
public static void Sub(t)
-
{
-
Console.WriteLine("{0} seconds is,{1} minutes, {2} seconds", t.secondsString, t.minutes, t.seconds);
-
Console.ReadLine();
-
Console.WriteLine("{0} seconds is {1} hours, {2} minutes, {3} seconds", t.secondsString, t.hours, t.minutes, t.seconds);
-
Console.ReadLine();
-
}
-
Any input would be greatly appreciated! Thanks!!
-Andy
1 1168
You need to put an identifier type in the Sub definition. The compiler doesn't konw what type of variable t is. Try this:
public static void Sub( TimeSpan t)
A couple more hints:
C# is case sensitive - make sure variables are cased properly
The variable you're assigning to goes on the left. The statement
seconds = t.seconds;
will copy the value out of t.seconds and put it into the variable seconds, which appears to be the opposite of what you want.
A Using statement creates a variable then throws it away automatically when that variable goes out of scope. Since you have no { and } around the lines after the Using statement, that means it has a scope of 1 line (the one immediately following). Put { and } around everything that needs to use the t variable.
good luck
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: DAVID SCHULMAN |
last post by:
I've been trying to perform a calculation that has been running into
an underflow (insufficient precision) problem in Microsoft Excel, which
calculates using at most 15 significant digits. For this...
|
by: James Thurley |
last post by:
According to the docs, floats are 32 bit and doubles are 64 bit. So
using floats should be faster than using doubles on a 32 bit processor,
and my tests confirm this. However, most of the Math...
|
by: Kuba Florczyk |
last post by:
Hi
I've got some problem doing double buffer.
Here is my problem:
I've got custom control on which i paint some data (chat messages, lets call
it ChatControl), this control is puted on a...
|
by: Markus Kling |
last post by:
"double.Parse(double.MaxValue.ToString())" yields the following Exception:
Value was either too large or too small for a Double.
at System.Number.ParseDouble(String value, NumberStyles options,...
|
by: Xavier Osa |
last post by:
Hi,
I have an ASP.Net web page that you can download a file. As
Fergunson's problem, it prompts twice dialog boxes only if I select
Open button. If I select Save button, it prompts once.
I'm...
| |
by: Charles Law |
last post by:
I have a string similar to the following:
" MyString 40 "Hello world" all "
It contains white space that may be spaces or tabs, or a combination, and I
want to produce an array...
|
by: Rain |
last post by:
Hello Gurus!
I really need this one to finish a module in my thesis. PLease please help
me. I need a double buffer class so i can call it and use it anytime i want,
the problem is everything ive...
|
by: jim4u |
last post by:
I am porting a vb library to vb.net. The vb library has an external
call to an unmanaged dll.
Existing code:
//External function declaration
Private Declare Function Uncompress& Lib...
|
by: jim4u |
last post by:
I am porting a vb library to vb.net. The vb library has an external
call to an unmanaged dll.
Existing code:
//External function declaration
Private Declare Function Uncompress& Lib...
|
by: Yoavo |
last post by:
Hi,
I want to convert a string to double. I use the function:
"System.Convert.ToDouble".
The problem is that if the string contains the character "." the program
aborts.
What might be the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |