ok so im in college right computer science major first year and all and they still have pascal can you believe it wow so ne ways he gives out this assingment and the assingment is this i need to write a programm using delphi ythat would be able to name a prime number or a non prime number from 1 to 1000 and it needs to open the window when ran to ask you for a number and you enter a number press enter then it needs to decifer if it is a prime number or a non prime number i need help ANYONE PLEASE HELP!!!!

ok so i got some of it done i need help on the function part sooooo i find that to be the hardest ne one with ne suggestions or or ne thing

so, you think that pascal is old fashion, and you want to use delphi(you got charmed probably about drag-drop,click and the program is finished) but you aren't able to find if a number is prime or not?

what you have done until now? post some code of what you accomplished and we'll help you.

best regards,

ok so you want me to put up some code to show i know it and not just copping out or something is wut your getting out and its not that i need to know what a prime number is or if it is prime it is having the program tell me its prime .....

heres some code actually a program run it and tell me wut u think

heres guys heres my code you guys wanted i just need help with this oother program and actually my whole class is stumped and thats why im here im lost on this im looking for help not for you guys to do it ya and thanx

this is it and so far nothing ne help would be appreciated please and thank you

SysUtils;

{$APPTYPE CONSOLE}
// the start of the function
Function Prime


// the begging of thine main program

var
num : integer;

begin
writeln(' Enter a number from 1 to 1000 and push enter ');
readln(num);


end.

this is the entire code i have found in your file! what i think? well, you made an console application which is showing a text on screen, and read an integer from keyboard.

in that file it is explained very well which is the mecanism of finding a prime number! you don't know how to implement the procedure/function or what?

best regards,

in way i do and it sounds like your bashing me and i said i needed help starting it thats what i said man and open up the other one thats there too above the one you opened so you know i know what im doing and btw man im not a top flight programmer thats why im here

you don't need to be an top programmer, you must want to learn, and try to understand. this is a very simple task which could be done if you took a delphi book, and try to accomplish it

code:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
       function prime(number:integer):string;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption:=prime(strtoint(edit1.Text));
end;

function TForm1.prime(number:integer): string;
var i:integer;
    prime:boolean;
begin
Label1.Caption:='';
prime:=true;
result:='prime';
if (number=1) or (number=2) or (number=3) then prime:=true
else
for i:=2 to round(sqrt(number)) do
if number mod i=0 then
 begin
  prime:=false;
  result:='not prime';
  exit;
 end;
end;

end.

hope you'll try to understand this program, not only to copy it and past it.

best regards,

thank you for your help and i am trying to learn like i said and i understand a little bit of wut you put but now that i got your help i will use my book that i have been using and see wut you did ya know anhd then figure it out that way thanx again for all your help and if i have any more qs may i ask you?

you don't need to ask me, post your questions over here, and if somebody can help then you'll receive your help

best regards,

As long as you're at it, here is how you get the program to run your Prime method when the Enter key is pressed without including a button:
1. Set the KeyPreview property of your form to True.
2. Go to the Events page of the form and double-click in the empty space to the right of the OnKeyDown event. This will create an empty method for this event.
3. In the event Delphi generates, add this code:
if Ord(Key) = VK_Return then (call your Prime function here)
Note that VK_Return is a constant defined as an integer, so you need to cast the Key value passed to your method before you can compare it to the character which you typed.

PS-They still teach Delphi in (good) schools because it is one of the best development tools for Windows and not too bad for Web and NET apps too.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.