הרשם שאלות ותשובות רשימת חברים לוח שנה הודעות מהיום

חזור   הוסטס - פורום אחסון האתרים הגדול בישראל > עיצוב גראפי, תכנות על כל שפותיו וקידום ושיווק אתרים > פורום תיכנות

   
|!|

 
 
כלים לאשכול תצורת הצגה
Prev הודעה קודמת   הודעה הבאה Next
ישן 15-09-06, 16:45   # 15
Matchs
תודה על תרומתך.
 
מיני פרופיל
תאריך הצטרפות: Oct 2005
מיקום: מרכז.
הודעות: 935

Matchs לא מחובר  

ציטוט:
נכתב במקור על ידי omaniusd
סבבה.
קוד:
 //הגדרת משתנים
            int num1;
            int num2;
            //קבלת קלט
            Console.WriteLine("Enter two numbers' please");
            num1 = Convert.ToInt32(Console.ReadLine()); //עשיתי גם המרה
            num2 = Convert.ToInt32(Console.ReadLine());
            if(num2==0) //בדיקה אם המחלק שווה לאפס
            {
                Console.WriteLine("I'm Sorry. I can't divide zero");
            }
            else //אם הפעולה תקינה
            {
                Console.WriteLine(num1/num2);
            }
            Console.Read(); //שהאפליקציה תמתין לקלט לסיום
עשיתי בדיוק מה שאמרת, רק בלי ELSE - ועכשיו הכל פועל נהדר!
למי שרוצה לראות מחשבון בסיסי עם 2 מספרים ופעולות, בשפת סי-שארפ (אשמח לתגובות וכמובן ממך omaniusd):

PHP קוד:
using System;
using System.Collections.Generic;
using System.Text;

namespace Calculator
{
    class 
Program
    
{
        static 
void Main(string[] args)
        {
            
int A;
            
int B;
            
char C;

            
Console.WriteLine("Welcome to C# calculator!");
            
Console.WriteLine("Made by Rotem the programmer :P");

            
Console.WriteLine();

            
Console.Write("Please insert the first number: ");
            
int.Parse(Console.ReadLine());

            
Console.Write("Please insert the second number: ");
            
int.Parse(Console.ReadLine());

            
Console.Write("Please insert an action: ");
            
char.Parse(Console.ReadLine());

            if ((
== '/') || (== 0))
            {
                
Console.WriteLine();
                
Console.WriteLine("You can't division by zero!");
                
Console.Read();
            }

            else
            {
                switch (
C)
                {
                    case 
'+':
                        
Console.WriteLine("The Result: {0} {1} {2} = {3}"ACBB);
                        
Console.Read();
                        break;

                    case 
'-':
                        
Console.WriteLine("The Result: {0} {1} {2} = {3}"ACBB);
                        
Console.Read();
                        break;

                    case 
'*':
                        
Console.WriteLine("The Result: {0} {1} {2} = {3}"ACBB);
                        
Console.Read();
                        break;

                    case 
'/':
                        
Console.WriteLine("The Result: {0} {1} {2} = {3}"ACBB);
                        
Console.Read();
                        break;

                    default:
                        
Console.WriteLine("There is a problem! :(");
                        break;
                }
            }
        }
    }

__________________
לפניות, אנא השאירו לי הודעה פרטית.
Matchs.
  Reply With Quote
 

חברים פעילים הצופים באשכול זה: 1 (0 חברים ו- 1 אורחים)
 


חוקי פירסום
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is מופעל
סמיילים הם מופעל
[IMG] קוד מופעל
קוד HTML מכובה

קפיצה לפורום


כל הזמנים הם GMT +2. הזמן כעת הוא 01:41.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ