عرض مشاركة واحدة
منتديات طلاب وطالبات جامعة الملك عبد العزيز منتديات طلاب وطالبات جامعة الملك عبد العزيز
قديم 18-12-2011, 03:19 AM   #2

deathpain

devkemo

الصورة الرمزية deathpain

 
تاريخ التسجيل: Dec 2010
كلية: كلية الحاسبات وتقنية المعلومات
التخصص: Computer Science
نوع الدراسة: إنتظام
المستوى: الثامن
البلد: جــــدة
الجنس: ذكر
المشاركات: 770
افتراضي رد: Cpcs 202 شروحات وحلول وواجبات الجافا

المشاركة الأصلية كتبت بواسطة aroomh مشاهدة المشاركة
conversion from kilogram to pounds write a program that displays the following two tables side-by-side(note that 1 kilogram is 2.2 pounds)

kilograms pounds pounds kilograms
9.09 20 2.2 1
11.63 25 6.6 3
....
231.82 510 433.4 197
234.09 515 437.8 199
NOTE:
use the following menu for conversion
1:for conversion from kg to pounds
2:for conversion from pounds to kg
3:to exit from the program execution
الحل:
كود PHP:
package kg2pound;
import java.util.*;
public class 
Kg2Pound {
    public static 
void main(String[] args) {
    
Scanner input=new Scanner(System.in);
    
int option=0;
    
double kg=0,pound=0;
    while (
true){
    
System.out.print("\nEnter a command number: \n"
            
+"1- Convert from Kilograms to Pounds\n"
            
+"2- Convert from Pounds to Kilograms\n"
            
+"3- Exit\n");
    
option=input.nextInt();
    if (
option==1){
    
System.out.print("Enter your weight in Kilograms to convert to Pounds: ");
    
kg=input.nextDouble();
    
pound=kg/2.2;
    
System.out.print("Kilograms\tPounds\n");
    
System.out.print(kg+"\t\t"+pound);}
    else if (
option==2){
    
System.out.print("Enter your weight in Pounds to convert to Kilograms: ");
    
pound=input.nextDouble();
    
kg=pound*2.2;
    
System.out.print("Pounds\tKilograms\n");
    
System.out.print(pound+"\t"+kg);}
    else if (
option==3)
    
System.exit(0);
    }
    }

بالتوفيق يا رب

 

توقيع deathpain  

 



في حال وجود أي استفسار أو سؤال حول الجافا CPCS202 الرجاء كتابة استفسارك مباشرة في موضوعي هنا:

تطبيق - معدلي الجامعي - التطبيق الأسهل لحساب المعدل الجامعي
http://skaau.com/vb/showthread.php?t=745520

 

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