TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Maha
NA
0
326.4k
If - Else
Jan 18 2012 8:41 AM
In the following Program when zone1 or zone2 and quantity less or equal to 10 delivery is free. But Program is giving following wrong result. Please fix the error.
Zone 1
Quantity 9
Not free
using System;
namespace DemoORAndAND
{
class Program
{
static void Main(string[] args)
{
const int ZONE1 = 1, ZONE2 = 2;
const int LOWQUANTITY = 10;
int quantity;
int diliveryZone;
Console.WriteLine("Delivery is free for zone {0} or {1}", ZONE1, ZONE2);
Console.WriteLine("...when the number of boxes is less than {0}", LOWQUANTITY);
quantity = method("\nZone ");
diliveryZone = method("Quantity ");
if ((diliveryZone == ZONE1 || diliveryZone == ZONE2) && quantity <= LOWQUANTITY)
Console.WriteLine("Free");
else
Console.WriteLine("Not free");
Console.ReadKey();
}
public static int method(string s)
{
int num;
Console.Write(s);
num = Convert.ToInt32(Console.ReadLine());
return num;
}
}
}
Reply
Answers (
4
)
Public token key
How to log my url of the sites visited