I have been trying to debug this code for the last 2 days. Somebody help. I am new to programming.

Posted by Mutio under C# on 3/5/2013 | Points: 10 | Views : 1093 | Status : [Member] | Replies : 1
using System;

namespace Assignment
{
class Birth
{
private int age;
public int getage
{
get {return age;}
set {if (1 <= ageinput <= 100) {age = ageinput;} else {age = 0;}}
}
public void Birth_date ()
{
public int dateofbirth;
if (age != 0){dateofbirth = 2013 - age; console.WriteLine ("Your birth date is:- " + dateofbirth);

if ((dateofbirth % 4) == 0 && (dateofbirth % 100) != 0 || (dateofbirth % 400) == 0) {Console.WriteLine (); Console.WriteLine ("You was born in a leap year");}
else {Console.WriteLine ();}
}

else {console.WriteLine ("Error ... Age out of range !!!");}

console.WriteLine ("Press any key to continue ...");
}
}

class Program_Create_Birth
{

public static void Main (string[] args)
{
int ageval;
public string input;
public int ageinput;
Console.WriteLine ("Enter age between 1..100 :-");
input = Console.ReadLine ();
ageinput = Convert.ToInt32 (input);
Birth entry = new Birth (ageinput);
entry.getage = ageinput;
entry.Birth-date ();

}
}
}





Responses

Posted by: Mutio on: 3/5/2013 [Member] Starter | Points: 25

Up
0
Down
these are the errors I am getting
assignment.cs(14,4): error CS1513: } expected
assignment.cs(16,4): error CS1519: Invalid token 'if' in class, struct, or
interface member declaration
assignment.cs(16,12): error CS1519: Invalid token '!=' in class, struct, or
interface member declaration
assignment.cs(17,17): error CS1519: Invalid token '=' in class, struct, or
interface member declaration
assignment.cs(17,29): error CS1519: Invalid token ';' in class, struct, or
interface member declaration
assignment.cs(17,49): error CS1519: Invalid token '(' in class, struct, or
interface member declaration
assignment.cs(17,87): error CS1519: Invalid token ')' in class, struct, or
interface member declaration
assignment.cs(19,21): error CS1519: Invalid token '%' in class, struct, or
interface member declaration
assignment.cs(19,47): error CS1519: Invalid token '%' in class, struct, or
interface member declaration
assignment.cs(19,75): error CS1519: Invalid token '%' in class, struct, or
interface member declaration
assignment.cs(19,107): error CS1519: Invalid token '(' in class, struct, or
interface member declaration
assignment.cs(19,129): error CS1519: Invalid token '(' in class, struct, or
interface member declaration
assignment.cs(20,4): error CS0116: A namespace does not directly contain members
such as fields or methods
assignment.cs(23,4): error CS0116: A namespace does not directly contain members
such as fields or methods
assignment.cs(26,3): error CS1022: Type or namespace definition, or end-of-file
expected



Mutio, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response