Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

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:

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));
}
}
}
}

Edited by PlausiblyDamp

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...