الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

عندي مشروع بسييط - بس المشكله مابقي الا يوم على تسليمه

مغلق
بدأه alfarees في 25 مايو 2007 · 5 رد · 609 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

سلام عليكم

اخواني الاعزاء

لدي مشروع عمل برنامج بلغه الجافا

و انا اشغلت بالدراسه عنه و ما بقى الا يوم واحد لتسليمه

يعني لازم يوم الاحد يكون مسلم

ياريت تساعدوني فيه و الله يجزاكم الف خييير

لان له نسبه كبيره في علاماتي النهائيه فياريت ما تبخلوا علي

تفاصيل المشروع هي كالتالي:

-------------------------------------

Project II

Write a menu-driven JAVA program that uses a one dimensional array to store information about items in a computer hardware store. The information required is: ID number of the item, item name, number of items in stock, and price. The program should display and execute the following options:

Read Data reads records from a file called “input.txt” and stores the information in a one dimensional array of objects. Computer hardware items can only be stored if their ID is unique. If the computer hardware ID already exists, the computer hardware item that has just been read, should be ignored, and an error message should be displayed “[Computer hardware item] has a duplicate ID as [Name]” where [Computer hardware item] is the name of the computer hardware item just read and [Name] is the computer hardware item with duplicate ID. Upon reading (and subsequently storing) the 'item name', you must remove all instances of under-scores (_) and replace them with blank spaces.

Display Items displays all computer hardware items. Display Items with an extra column that shows the computer hardware item price including Tax (Tax is calculated at 10% + Price)

Sort Computer Hardware List, sorts and displays records (ID, Item, Number of items, Price, Price + Tax) in descending order of price.

Search for Hardware Item asks the user to Search for Hardware Item enter a computer hardware item ID, searches all records for the ID entered by the user and displays an appropriate message as follows:

Item [iD] [computer hardware item] found

OR [iD] not found.

Write to File & Exit writes the contents of the one dimensional array of objects to the file "input.txt" (overwriting the old contents) and exits the program. Note: a computer hardware item name should be written to the file with underscores in place of blank spaces.

Note: [iD] is to be substituted with the computer hardware item ID i.e. “2222” and [computer hardware item] is to be substituted by the actual computer hardware item name i.e. “Hard Drive”.

Important:

The output should be displayed on the screen.

You can use any type of sorting you know

You must use a one dimensional array to store the objects.

You must write 5 separate methods (read, display, search, sort, and write).

You can assume that the maximum number of customer records will be 50.

There can be up to 50 records but we don’t know the exact number.

Format for Input Data FILE "input.txt" (Sample only)

1234 Hard Drive 21 87.99

2222 Flash Drive 7 38.00

1567 Motherboard 5 128.84

اتمنى انكم تساعدوني في عمله و لكم جزييل الشكر

تحياتي

#3
اقتباس
هذه مشكلتك ما هي مشكلتنا

هذا بالاضافة انك مخالف شروط المنتدى وفي اقرب مرور لمشرف ستغلق مشاركتك

#4

انا عارف اني غلطااان و هذا الشي غلط

بس للاسف هذا اللي صار معااي

و انا اسف و الله اسف

اتمنى انكم تقبلوا اعتذاري و تساعدوني

انا حاولت اكتب البرنامج اليوم و هذا اللي طلع معاي

--------------------------------------

public class Item

{

public int id, number;

public String name;

public double price, tax;

public Item(int x , String y, int z, double i )

{

id=x;

name=y;

number=z;

price=i;

}

public String toString()

{

tax= (price*10)/100;

return (id +"\t" + name +"\t" + number + "\t" + price + "\t" + tax);

}

}

-------------------------------------

و هذا المف الرئيسي للبرنامج:

-------------------------------------------------

import java.util.*;

import java.io.*;

public class Store

{

private Item[] array;

public static void main (String[] args)

{

int key;

Scanner input = new Scanner (System.in);

while(key>=0)

{

System.out.println("This program have 5 different method, please choce one of them by enter the number of the method");

System.out.println("1\\Read Data.");

System.out.println("2\\Display Item.");

System.out.println("3\\Sort Computer Hardware List.");

System.out.println("4\\Search for Harware Item.");

System.out.println("5\\Write to file & Exit.");

key= input.nextInt();

switch(key)

{

case 1:

Store.readData();

break;

case 2:

Store.displayItem(array);

break;

case 3:

Store.sort(array,4);

break;

case 4:

Store.search(array);

break;

case 5:

Store.writeFile(array);

break;

default:

System.out.println("The number you enterd is not correct..Please Enter a new number.");

}

}

}

public static Item[ ] readData()

{

try

{

Scanner input = new Scanner(new File ("input.txt"));

}

catch(FileNotFoundException e)

{

System.out.println("Problem opening files.");

System.exit(0);

}

Scanner input = null;

array=new Item[50];

for(int k=0 ; k<array.length ; k++)

{

while (input.hasNextLine())

{

array[k].id = input.nextInt();

array[k].name =input.next();

array[k].number = input.nextInt();

array[k].price = input.nextDouble();

}

return array[k]= new Item (array[k].id, array[k].name , array[k].number , array[k].price);

}

input.close();

}

public static void displayItem(Item[] array)

{

for(int x=0 ; x< array.length ; x++)

System.out.println(array[x]);

}

public static void sort(Item[] array, int numberUsed)

{

int index, indexOfNextSmallest;

for (index = 0; index < numberUsed - 1; index++)

{

indexOfNextSmallest = indexOfSmallest(index, array, numberUsed);

interchange(index,indexOfNextSmallest, array);

System.out.println("The array after sorting will be:");

for(int y=0 ; y<array.length ; y++)

System.out.print(array[y]);

}

}

private static int indexOfSmallest(int startIndex, Item[] array, int numberUsed)

{

double min = array[startIndex];

int indexOfMin = startIndex;

int index;

for (index = startIndex + 1; index < numberUsed; index++)

if (array[index].price < min)

{

min = array[index].price;

indexOfMin = index;

}

return indexOfMin;

}

private static void interchange(int i, int j, Item[] array)

{

double temp;

temp = array.price;

array.price = array[j].price;

array[j].price = temp;

}

public static boolean search(Item[] array)

{

Scanner input= new Scanner (System.in);

System.out.println("Enter an item number to see if it in the record:");

System.out.println("You will get TRUE if it is avialable and FALSE if it isn't avialable.");

int searchNumber = input.nextInt();

for(int i=0 ; i<array.length ; i++)

{

if(array.id== searchNumber)

return true;

break;

}

return false;

}

public void writeFile()

{

PrintWriter output = null;

try

{

output = new PrintWriter(new File ("input.txt"));

}

catch(FileNotFoundException e)

{

System.out.println("Problem opening files.");

System.exit(0);

}

for(int i=0 ; i<array.length ; i++)

output.print(array.id + "\t" + array.name +"\t" + array.number +"\t" + array.price);

System.exit(0);

}

}

*************************

اتوقع اني كذا ما خالفت النظااام

فياريت تساعدوني في حل المشكلات اللي فيها قبل اخر الليل و لكم مني جزييل الشكر

تحياتي

#5
import java.util.*;
import java.io.*;
 class Item
{
public int id, number;
public String name;
public double price, tax;

public Item(int x , String y, int z, double i )
{
id=x;
name=y;
number=z;
price=i;
}
public String toString()
{
tax= (price*10)/100;
return (id +"\t" + name +"\t" + number + "\t" + price + "\t" + tax);
}
}

 class Store{
private static Item[] array=new Item[50];
private static int actualRecords=0;

public static void main (String[] args)
{
int key=0;
Scanner input = new Scanner (System.in);
while(key>=0)
{
System.out.println("This program have 5 different method, please choce one of them by enter the number of the method");
System.out.println("1\\Read Data.");
System.out.println("2\\Display Item.");
System.out.println("3\\Sort Computer Hardware List.");
System.out.println("4\\Search for Harware Item.");
System.out.println("5\\Write to file & Exit.");
key= input.nextInt();
switch(key)
{
case 1:
array=Store.readData();
break;
case 2:
Store.displayItem(array);
break;
case 3:
Store.sort(array,4);
break;
case 4:
Store.search(array);
break;
case 5:
Store.writeFile();
break;
default:
System.out.println("The number you enterd is not correct..Please Enter a new number.");

}
}

}

public static Item[ ] readData()
{Scanner input=null;
try
{
 input = new Scanner(new File ("input.txt"));

while (input.hasNextLine())
{
array[actualRecords]=new Item(input.nextInt(),input.next(), input.nextInt(),input.nextDouble());
actualRecords++;
}
}
catch(FileNotFoundException e)
{
System.out.println("Problem opening files.");
System.exit(0);
}

input.close();
return array;
}

public static void displayItem(Item[] array)
{
for(int x=0; x< actualRecords; x++)
System.out.println(array[x]);
}

public static void sort(Item[] array, int numberUsed)
{
int index, indexOfNextSmallest;
for (index = 0; index < numberUsed - 1; index++)
{
indexOfNextSmallest = indexOfSmallest(index, array, numberUsed);
interchange(index,indexOfNextSmallest, array);

System.out.println("The array after sorting will be:");
for(int y=0; y<actualRecords; y++)
System.out.print(array[y]);
}
}

private static int indexOfSmallest(int startIndex, Item[] array, int numberUsed)
{
double min = array[startIndex].price;
int indexOfMin = startIndex;
int index;
for (index = startIndex + 1; index < numberUsed; index++)
if (array[index].price < min)
{
min = array[index].price;
indexOfMin = index;
}
return indexOfMin;
}

private static void interchange(int i, int j, Item[] array)
{
double temp;
temp = array.price;
array.price = array[j].price;
array[j].price = temp;
}


public static boolean search(Item[] array)
{
Scanner input= new Scanner (System.in);
System.out.println("Enter an item number to see if it in the record:");
System.out.println("You will get TRUE if it is avialable and FALSE if it isn't avialable.");
int searchNumber = input.nextInt();
for(int i=0; i<array.length; i++)
{
if(array.id== searchNumber)
return true;
break;
}
return false;
}

public static void writeFile()
{
PrintWriter output = null;

try
{
output = new PrintWriter(new File ("input.txt"));
for(int i=0; i<actualRecords; i++)
output.print(array.id + "\t" + array.name +"\t" + array.number +"\t" + array.price);
output.println();
output.flush();
}
catch(FileNotFoundException e)
{
System.out.println("Problem opening files.");
System.exit(0);
}

System.exit(0);
}


}

حاولت قدر الامكان ، بس ماجربت البرنامج ، جرب وشوف يمكن يحتاج تعديلات بسيطه

#6

مشكوووووووووووور يا عزيزي

جاري تجربه البرنامج

و لو احد عنده اي اضافات او تعديلات ياريت يساعدني

تحياتي

هذا الموضوع مغلق.

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…