Which of the following C# expressions means, "If itemNumber is 5 and zone is 1 or 3, add TAX to price"? A: if (itemNumber = 5 && (zone = 1 || zone = 3))price = price + TAX; b. two of these C: if (itemNumber = && zone == 1 || zone price = price + TAX;   D: if (itemNumber = 5 && (zone=1 || 3))price = price + TAX;

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter4: Making Decisions
Section: Chapter Questions
Problem 17RQ: Which of the following C# expressions means, If itemNumber is not 8 or 9, add TAX to price?...
icon
Related questions
icon
Concept explainers
Question

Which of the following C# expressions means, "If itemNumber is 5 and zone is 1 or 3, add TAX to price"?

A: if (itemNumber = 5 && (zone = 1 || zone = 3))price = price + TAX;

b. two of these

C: if (itemNumber = && zone == 1 || zone price = price + TAX;

 

D: if (itemNumber = 5 && (zone=1 || 3))price = price + TAX;

Expert Solution
Step 1

Option A:

 if (itemNumber = 5 && (zone = 1 || zone = 3))price = price + TAX;

Explanation:

This option is incorrect because the comparison operator == should be used instead of the assignment operator = in the condition itemNumber = 5 and zone = 1 or zone = 3.

The assignment operator = sets the value of a variable, while the comparison operator == compares the value of two variables.

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Control Structure
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT