« 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: De_Composed in 6TH POPE | Recommend this post (1)
Wed, 20 Mar 24 12:02 AM | 37 view(s)
Boardmark this board | 6th Edition Pope Board
Msg. 51274 of 60008
(This msg. is a reply to 51271 by De_Composed)

Jump:
Jump to board:
Jump to msg. #

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.


- - - - -
View Replies (2) »



» 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
Tue, 19 Mar 24 11:30 PM
Msg. 51271 of 60008

scubavol:

Re: “and found almost every result to be underwhelming.”
How interested in computers would you have been in the 1970s if all you'd been shown was an Apple I microcomputer? Or a Commodore Pet? Neither had any useful applications, and if you didn't understand that what you were seeing was only the tip of the iceberg, you wouldn't have been impressed.

That's where we are with AI. Revisit this thread in ten years and see if your outlook has changed.






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