عرض مشاركة واحدة
منتديات طلاب وطالبات جامعة الملك عبد العزيز منتديات طلاب وطالبات جامعة الملك عبد العزيز
قديم 10-04-2013, 09:21 PM   #495

بنفسي اصنع سعادتي

جامعي

الصورة الرمزية بنفسي اصنع سعادتي

 
تاريخ التسجيل: Nov 2010
كلية: كلية الاقتصاد والادارة
التخصص: علوم إدارية
نوع الدراسة: إنتساب
المستوى: متخرج
البلد: جــــدة
الجنس: أنثى
المشاركات: 153
افتراضي رد: Cpcs 202 شروحات وحلول وواجبات الجافا

آلله يخليكككم اللي يعرف آآلحل لايبخل علي :(

Project2 Deion:
A Shipping Company charges cargoes in Saudi Arabia based on the following rates :

Weight of the Cargo (in KG) Shipping Rate per KM
2 kg or less SR 0.25
Over 2 kg, but not more than 10 kg SR 0.2
Over 10 kg, but not more than 20 kg SR 0.15
Over 20 kg, but not more than 50 kg SR 0.2
table 1
Shipping charges for the Gulf countries costs 2% more and 5% more for other countries.
write a Java program thatallows the user to enter the weight of the cargo , the place and
the distance it is to be shipped(Saudi Arabia, Gulf country or other) and then displays the charges.

Input validation:
The user has to enter S (for shipping in Saudi Arabia) ,G (for shipping to Gulf countries) , O (for shipping to other countries). Next, the user will enter a value cargo weight and the distance . The program will calculate the charges according totable 1. The output of the program should be the shipping charges. In addition, consider the following scenarios in the output:
1. If the user inputs a character that is not recognized (NOT S, G, orO), then the program prints “Wrong Selection!”, and exits.
2. If the user inputs0 or less for the value of the cargo weight, the program will display a message that states “the weight must be larger than Zero!”
3. The maximum weight the companywill ship is 50 KG, So if the user enter more than 50 KG, the program will display “the weight must not exceed 50KG!”
4. These are the company’s minimum and maximum shipping distances. So your program should not accept distances of less than 10 Km or more than 5000 KM. Display an appropriate message to the user if entered unaccepted distance.
5. After displaying the shipping charge,the program should also display the discountfor the charges value according to the following rules:
a. If charges value is less than or equalSR 1000, print “Discount is 0 %.”
b. If charges value is less than 10000, print “Discount is 5%.”
c. If charges value is greater than or equal 10000, print “Discount is 10%.”


The program should display a Menu for the user to choose from. The menu is shown in the figure below.

Welcome to Shipping System
Press S for shipping in Saudi Arabia
Press G for shipping to Gulfcountries
Press O for shipping to other countries

Note: Submit only the source code. For example: IA_1110348_P2.java
Sample Program Run #1:

Welcome to Shipping System

Press S for shipping in Saudi Arabia
Press G for shipping to Gulfcountries
Press O for shipping to other countries

G

Enter a value for the cargo weight:20
Enter a value for the distance: 450

Discount is 5%

The Charge ofYour20KG Cargo will be 1308.15 SR.









Sample Program Run #2:
Welcome to Shipping System

Press S for shipping in Saudi Arabia
Press G for shipping to Gulfcountries
Press O for shipping to other countries

Z
Wrong Selection!




Sample Program Run #3:
Welcome to Shipping System

Press S for shipping in Saudi Arabia
Press G for shipping to Gulfcountries
Press O for shipping to other countries

O
Enter a value for the cargo weight:60
the weight must not exceed 50KG!

 

بنفسي اصنع سعادتي غير متواجد حالياً   رد مع اقتباس