Click here to Skip to main content
15,898,768 members
Home / Discussions / C#
   

C#

 
GeneralRe: # color Pin
Luc Pattyn24-Oct-07 12:38
sitebuilderLuc Pattyn24-Oct-07 12:38 
Questionauto-method [modified] Pin
MasterSharp24-Oct-07 10:55
MasterSharp24-Oct-07 10:55 
AnswerRe: auto-method Pin
il_masacratore24-Oct-07 11:12
il_masacratore24-Oct-07 11:12 
GeneralRe: auto-method Pin
MasterSharp24-Oct-07 11:22
MasterSharp24-Oct-07 11:22 
GeneralRe: auto-method Pin
Christian Graus24-Oct-07 12:28
protectorChristian Graus24-Oct-07 12:28 
QuestionModular Program Pin
murtle324-Oct-07 9:38
murtle324-Oct-07 9:38 
QuestionRe: Modular Program Pin
TJoe24-Oct-07 9:48
TJoe24-Oct-07 9:48 
AnswerRe: Modular Program Pin
murtle324-Oct-07 19:06
murtle324-Oct-07 19:06 
Yeah, it compiles fine because I copy and pasted the original coding without what I put in when I tried to make it modular. What I tried to do looked something like this:

<pre>
using System;
using System.Collections.Generic;
using System.Text;

namespace Program5
{
class Program
{
const double DEPINS = 25.50;
const double TAX = .23;
static void GetData()
{
int dep;
double grossPay, hourRate, hourWorked, deduct, netPay, depIns, tax;

Console.Write("Hours Worked: ");
hourWorked = Double.Parse(Console.ReadLine());

Console.Write("Hourly Rate: ");
hourRate = Double.Parse(Console.ReadLine());

Console.Write("Dependents: ");
dep = Int32.Parse(Console.ReadLine());
}

static void CalcNet()
{

if (hourWorked >= 40)
grossPay = Math.Round(1.5 * hourRate * hourWorked, 2);

else
grossPay = Math.Round(hourRate * hourWorked, 2);


depIns = dep * DEPINS;
tax = grossPay * TAX;
deduct = Math.Round(depIns + tax, 2);
netPay = grossPay - deduct;
}

static void DspData()
{
Console.WriteLine("");
Console.WriteLine("Hours Worked: {0,9:n}", hourWorked);
Console.WriteLine("Hourly Rate: {0,9:n}", hourRate);
Console.WriteLine("Dependents: {0,9}", dep);
Console.WriteLine("Gross Pay: {0,9:n}", grossPay);
Console.WriteLine("Deductions: {0,9:n}", deduct);
Console.WriteLine(" ---------");
Console.WriteLine("Net Pay: {0,9:c}", netPay);
}
static void Main ()
{
GetData();
CalcNet();
DspData();
}
</pre>

So what I did is I set it up exactly like it was set up in an example program from my notes which I copy and pasted and compiled and that worked just fine, but when I do it with this program it says my namespace is invalid and that I need a semi-colon after the static void's which I know is incorrect. So I have no idea what is going on.

GeneralRe: Modular Program Pin
PandemoniumPasha24-Oct-07 19:30
PandemoniumPasha24-Oct-07 19:30 
GeneralRe: Modular Program Pin
murtle324-Oct-07 19:38
murtle324-Oct-07 19:38 
AnswerRe: Modular Program Pin
PandemoniumPasha24-Oct-07 19:51
PandemoniumPasha24-Oct-07 19:51 
GeneralRe: Modular Program Pin
murtle325-Oct-07 4:02
murtle325-Oct-07 4:02 
AnswerRe: Modular Program Pin
Christian Graus24-Oct-07 12:52
protectorChristian Graus24-Oct-07 12:52 
QuestionHow to remove part of the text in RichTextBox Pin
Ermak8624-Oct-07 9:05
Ermak8624-Oct-07 9:05 
AnswerRe: How to remove part of the text in RichTextBox Pin
TJoe24-Oct-07 9:27
TJoe24-Oct-07 9:27 
GeneralRe: How to remove part of the text in RichTextBox Pin
Ermak8624-Oct-07 10:02
Ermak8624-Oct-07 10:02 
AnswerRe: Open Default Defragmenter Pin
TJoe24-Oct-07 9:00
TJoe24-Oct-07 9:00 
GeneralRe: Open Default Defragmenter Pin
andyr200524-Oct-07 9:08
andyr200524-Oct-07 9:08 
Questionvariable out of scope Pin
Payrok24-Oct-07 8:07
Payrok24-Oct-07 8:07 
AnswerRe: variable out of scope Pin
TJoe24-Oct-07 8:16
TJoe24-Oct-07 8:16 
AnswerRe: variable out of scope Pin
Guffa24-Oct-07 8:59
Guffa24-Oct-07 8:59 
AnswerRe: variable out of scope Pin
Pete O'Hanlon24-Oct-07 9:05
mvePete O'Hanlon24-Oct-07 9:05 
GeneralRe: variable out of scope Pin
Payrok24-Oct-07 9:09
Payrok24-Oct-07 9:09 
GeneralRe: variable out of scope Pin
TJoe24-Oct-07 9:10
TJoe24-Oct-07 9:10 
GeneralRe: variable out of scope Pin
Pete O'Hanlon24-Oct-07 9:16
mvePete O'Hanlon24-Oct-07 9:16 

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.