0% found this document useful (0 votes)
15 views5 pages

Lolo Java

The document contains a Java program that manages a list of expenses using an ArrayList. It allows users to insert, delete, search for, find the minimum, calculate the total, and print all prices through a menu-driven interface. The program continues to run until the user chooses to exit by pressing 7.

Uploaded by

otoomzzz000
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views5 pages

Lolo Java

The document contains a Java program that manages a list of expenses using an ArrayList. It allows users to insert, delete, search for, find the minimum, calculate the total, and print all prices through a menu-driven interface. The program continues to run until the user chooses to exit by pressing 7.

Uploaded by

otoomzzz000
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

‫();" يجب أن‬choice = s.

nextInt" ‫الخطأ األول هو أن جملة‬


‫ وليس خارجها‬،while ‫تكون داخل جملة‬

:‫الكود الصح‬

package expensbyaeeaylist;

import [Link].*;

public class ExpensByAeeayList {

public static void main(String[] args) {

ArrayList<Float> expenses = new


ArrayList<Float>();

Scanner s = new Scanner([Link]);

Float num;
Float min;
Float sum = 0f;
int choice;
boolean run = true;

while (run) {

[Link]("********************************"
);

[Link]("********************************"
);
[Link]("To insert new price
press 1.");
[Link]("To delete a price press
2.");
[Link]("To search for a price
press 3.");
[Link]("To find minimum price
press 4.");
[Link]("To find total price press
5.");
[Link]("To print all prices press
6.");
[Link]("To exit press 7.");

[Link]("********************************"
);
[Link]("********************************"
);

choice = [Link]();

switch (choice) {
case 1:
[Link]("Enter price");
num = [Link]();
[Link](num);
break;
case 2:
[Link]("Enter price");
num = [Link]();
[Link](num);
break;
case 3:
[Link]("Enter price");
num = [Link]();
if ([Link](num))
[Link]("price found");
else
[Link]("price not
found");
break;
case 4:
min = [Link](0);
for (int i = 1; i < [Link](); i++)
{
if (min > [Link](i))
min = [Link](i);
}
[Link]("minimum price is:
" + min);
break;
case 5:
for (int i = 0; i < [Link](); i++)
{
sum += [Link](i);
}
[Link]("Total price is: " +
sum);
break;
case 6:
[Link]("All prices are: " +
expenses);
break;
case 7:
run = false;
break;
default:
[Link]("not valid choice,
press number from 1 to 7");
break;
}
}

[Link]();
}
}

You might also like