CSCI 1301 Lecture Notes - Lecture 7: Boolean Expression, Man-In-The-Middle Attack, Gmail

64 views7 pages

Document Summary

Project 2 work on this for extra exam practice. Not operator is used to negate the value of a boolean expression. (!true is false) Mostly used to set a variable to one of two different values. Syntax: variable = boolean_condition ? value_1 : value_2. Example: if (n1>n2) els max = n1; max = n2; This can be written as: max = (n1 > n2) ? n1 : n2; Can also be used for a little complicated assignments but right of the operator ?" always returns a value. Example: if (hoursworked <= 40) pay = hoursworked * payrate; else pay = 40 * payrate + 1. 5 * payrate * (hoursworked-40) This can be written as: (hoursworked - 40)); pay = (hoursworked <= 40) ? (hoursworked * payrate) : (40 * payrate + 1. 5 * payrate * Switch statements public static void main(string[] args) int numberofdogs; Scanner keyboard = new scanner(system. in); numberofdogs = keyboard. nextint(); switch (numberofdogs)

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents