need help with my code

heather26

Newcomer
Joined
Jan 5, 2006
Messages
1
I am trying to write a programming code in Visual Studio and it is not working right when I enter the donor ID I get a message that says it is not found can anyone tell me what i am doing wrong
here is the code:
C#:
using System;

namespace ETS
{

struct myDonor
{
public string donorID ;
public string donorName;
public double donorAmt;
}
   
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
static string donorID;	 
static myDonor[] donor= new myDonor[3];
	
	
static void myDonor()
{
// initialize customer #1
donor[0].donorID = "B505";
donor[0].donorName = "Campbell";
donor[0].donorAmt = 50.00;

// initialize customer #2
donor[1].donorID = "D302";
donor[1].donorName = "Stewart";
donor[1].donorAmt = 200.00;

// initialize customer #3
donor[2].donorID = "M002";
donor[2].donorName = "Wright";
donor[2].donorAmt = 25.00;
}
static double getDonorAmt(string donorID)
{
double donorAmt = 0;

for (int i = 0; i < donor.Length-1; i++)
{
if (donorID == donor[i].donorID)
{
donorAmt = donor[i].donorAmt;
}
}
return donorAmt;
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)	
{
			
//AddDonors();

Console.WriteLine ("Please enter the donor ID: ");
donorID = Console.ReadLine();
if (getDonorAmt(donorID)==0)
{
Console.WriteLine ("Donor {0} does not exist.", donorID);
}
else
{
Console.WriteLine ("Donor {0} has donated {1}", donorID, getDonorAmt(donorID));
}
}
}
}
 
Last edited by a moderator:
Back
Top