CSCI 1301 Lecture Notes - Lecture 7: Boolean Expression, Man-In-The-Middle Attack, Gmail
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)