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

Plz Help Me To Solve It

بدأه hamedmf في 6 مارس 2008 · 6 رد · 835 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

Liz’s Taxi Service has proved so successful, boosted by her loyalty scheme for regular customers, that she has expanded her fleet to include vans and minibuses for hire, all driven by members of her highly-trained staff. Eager to maximise profits, she now wants to evaluate the efficiency of her drivers by logging each journey they make and analysing how swiftly they complete the job relative to the distance covered.

Each driver has a unique Driver Number. A journey takes place in a car, or van, or minibus (coded ‘C’, ‘V’ and ‘M’ respectively). The time taken (in whole minutes) and distance travelled (in whole miles) are both recorded.

To determine how speedily her drivers are working, Liz calculates the efficiency of each journey as the distance travelled divided by the time taken.*

Create a Java program to record each journey made by each driver in a file called journey.dat, and to perform various analysis tasks to assist Liz in monitoring driver efficiency. A typical line in the file might be

13 M 60 45

where driver 13 used a Minibus for 60 minutes and drove 45 miles. The efficiency value (calculated as necessary in the program, not stored in the file) would be 45 / 60 = 0.75

The system must be menu-driven and offer the following operations:

1.

Append a new line of journey data to the file;

2.

Provide a vehicle report for either

q

one specific category of vehicle (C / V / M) or for

q

each category of vehicle in turn (A for All)

showing for journeys in this vehicle either a

q

Summary (S) – number of journeys and average efficiency or a

q

Full report (F) – list of journeys (giving driver number and efficiency) plus summary information

3.

Provide a listing of the ten most efficient journeys (displaying driver number and efficiency value for each) in descending order. (Where fewer than ten journeys have been recorded all should be listed.)

4. exit from the system..

#2

هذا الحل: google ==> how to write to file in java

#3

شكرا على المساعده يا اخي

#4

is it right ?????

import java.io.*;

public class jINSERT {

public static void main(String args[]){

try {

jINSERT j = new jINSERT();

j.insertStringInFile

(new File(args[0]),Integer.parseInt(args[1]), args[2]);

}

catch (Exception e) {

e.printStackTrace();

}

}

public void insertStringInFile(File inFile, int lineno, String lineToBeInserted)

throws Exception {

// temp file

File outFile = new File("$$$$$$$$.tmp");

// input

FileInputStream fis = new FileInputStream(inFile);

BufferedReader in = new BufferedReader

(new InputStreamReader(fis));

// output

FileOutputStream fos = new FileOutputStream(outFile);

PrintWriter out = new PrintWriter(fos);

String thisLine = "";

int i =1;

while ((thisLine = in.readLine()) != null) {

if(i == lineno) out.println(lineToBeInserted);

out.println(thisLine);

i++;

}

out.flush();

out.close();

in.close();

inFile.delete();

outFile.renameTo(inFile);

}

}

تم تعديل هذه المشاركة بواسطة hamedmf في 6 مارس 2008 في 10:24

#5

هل فهمت ما موجود في هذا الكود؟

يعني هل تعرف كيف تستخدمه؟

إذا عرفت كيف تستخدمه ففيم السؤال؟

اقرأ أخي الكريم أولا و افهم فكرة العملية حتى تستطيع أن تسفيد منها

تم تعديل هذه المشاركة بواسطة qamber في 6 مارس 2008 في 17:40

#6

http://www.javapractices.com/topic/TopicAction.do?Id=42

هذه الوصلة مفيدة جدا

وتذكر حبيبي إذا ساعدناك بالطريقة التي تريد فتوقع أن يأتي اليوم الذي تدفع فيه ثمن هذا التهور.

تصور أنك في مستشفى والمعالج فيه أخذ الحل جاهزا تماما كما تحاول أن تحصل عليه فماذا تتوقع أن يخدمك ؟

هل تتوقع أن ينقذ حياتك ؟!!

#7

thanks fr ur advice my brother ...

ur alright ...

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