« 6TH POPE Home | Email msg. | Reply to msg. | Post new | Board info. Previous | Home | Next

Re: Which Careers Will Be Most Impacted by Artificial Intelligence?

By: unixguy in 6TH POPE | Recommend this post (0)
Wed, 20 Mar 24 3:38 PM | 27 view(s)
Boardmark this board | 6th Edition Pope Board
Msg. 51303 of 60008
(This msg. is a reply to 51274 by De_Composed)

Jump:
Jump to board:
Jump to msg. #

I have used to write firewall rules as well shell scripts, it's not 100% but 80%. As well it has written SuperBasic and Powershell for me.




» You can also:
- - - - -
The above is a reply to the following message:
Re: Which Careers Will Be Most Impacted by Artificial Intelligence?
By: De_Composed
in 6TH POPE
Wed, 20 Mar 24 12:02 AM
Msg. 51274 of 60008

I told ChatGPT to: write a pascal program that reads twenty dollar amounts and their dates, then produces a line graph as output.

The result, which the program generated immediately, follows. While the result isn't indented the way that a pascal program should be, ChatGPT's result did have it. It was atomicbobs that dropped the indenting and I'm too lazy to put it back in. To me, this is very impressive.


To create a Pascal program that reads twenty dollar amounts and their corresponding dates, and then produces a line graph as output, you would typically need to use a graphics library for drawing the graph. Below is an example using the Free Pascal Compiler (FPC) with the Graph unit for simple graphics:



pascal
Copy code
program DollarAmountGraph;

uses
Graph;

const
MaxEntries = 20;

type
Entry = record
Date: string;
Amount: Integer;
end;

var
GraphDriver, GraphMode: SmallInt;
ErrorCode: SmallInt;
Entries: array[1..MaxEntries] of Entry;
MaxAmount: Integer;
ScaleX, ScaleY: Integer;
i: Integer;

procedure InitializeGraph;
begin
GraphDriver := Detect;
InitGraph(GraphDriver, GraphMode, '');
ErrorCode := GraphResult;
if ErrorCode grOk then
begin
Writeln('Graphics error: ', GraphErrorMsg(ErrorCode));
Halt(1);
end;
end;

procedure ReadData;
var
i: Integer;
begin
for i := 1 to MaxEntries do
begin
Write('Enter date for entry ', i, ': ');
ReadLn(Entries[i].Date);
Write('Enter dollar amount for entry ', i, ': $');
ReadLn(Entries[i].Amount);
end;
end;

procedure FindMaxAmount;
var
i: Integer;
begin
MaxAmount := Entries[1].Amount;
for i := 2 to MaxEntries do
begin
if Entries[i].Amount > MaxAmount then
MaxAmount := Entries[i].Amount;
end;
end;

procedure DrawGraph;
var
i, X, Y: Integer;
begin
ClearDevice;
SetColor(White);
Line(50, 50, 50, GetMaxY - 50); // Y-axis
Line(50, GetMaxY - 50, GetMaxX - 50, GetMaxY - 50); // X-axis

SetColor(Yellow);
FindMaxAmount;
ScaleX := (GetMaxX - 100) div MaxEntries;
ScaleY := (GetMaxY - 100) div MaxAmount;

for i := 1 to MaxEntries do
begin
X := 50 + (i - 1) * ScaleX;
Y := GetMaxY - 50 - Entries[i].Amount * ScaleY;
Circle(X, Y, 3);
OutTextXY(X - 10, Y - 20, IntToStr(Entries[i].Amount));
OutTextXY(X - 10, GetMaxY - 40, Entries[i].Date);
if i < MaxEntries then
Line(X, Y, 50 + i * ScaleX, GetMaxY - 50 - Entries[i + 1].Amount * ScaleY);
end;

ReadLn; // Wait for user to close the graph window
CloseGraph; // Close the graphics mode
end;

begin
InitializeGraph;
ReadData;
DrawGraph;
end.



This program uses the Graph unit to draw the graph. Make sure you have a compatible Pascal compiler installed (such as Free Pascal Compiler) with support for the Graph unit. This code reads dates and dollar amounts for twenty entries, then draws a line graph representing the dollar amounts over the given dates. Adjustments may be necessary based on your specific requirements and environment.


« 6TH POPE Home | Email msg. | Reply to msg. | Post new | Board info. Previous | Home | Next