Chapter 3 Practice.

Slides:



Advertisements
Similar presentations
Modelling & Datatypes Koen Lindström Claessen. Software Software = Programs + Data.
Advertisements

Procedural Programming in C# Chapters Objectives You will be able to: Describe the most important data types available in C#. Read numeric values.
Chapter 3 DATA: TYPES, CLASSES, AND OBJECTS. Chapter 3 Data Abstraction Abstract data types allow you to work with data without concern for how the data.
Playing Cards Deck of 52 uniquely designed playing cards.
Java Syntax Part I Comments Identifiers Primitive Data Types Assignment.
Lesson 6 - Pointers Outline Introduction Pointer Variable Declarations and Initialization Pointer Operators Calling Functions by Reference Using the const.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 7 - Pointers Outline 7.1Introduction 7.2Pointer Variable Declarations and Initialization 7.3Pointer.
Solving One Step Equations and Inequalities Math 7/8.
1.2 & 1.3 Warm-Up. 1-2 Algebraic Expressions and Models An established ORDER OF OPERATIONS is used to evaluate an expression involving more than one operation.
Wednesday, October 27 Objective: Students will identify solutions of inequalities and write inequalities. Today’s Agenda: 1.No homework due today. 2.Fill.
Two equations are equivalent if they have the same solutions. Solving a Linear Equation An equation is a statement in which two expressions are equal.
1.3 Solving Linear Equations. Equation: a statement in which two expressions are equal Linear Equation- One variable equation that can be written as ax.
15.3 Counting Methods: Combinations ©2002 by R. Villar All Rights Reserved.
Chapter 7 Arrays. A 12-element array Declaring and Creating Arrays Arrays are objects that occupy memory Created dynamically with keyword new int c[]
Introduction to Computer Science 2 Slide 1 Enumerated types We already know some data types int, float, char good for problems that involve int,
Ch 1.4 – Equations & Inequalities
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
1 – 3 Solving Linear Equations Objective: CA 1.0: Students solve equations and inequalities involving absolute value.
Draw 3 cards without replacement from a standard 52 card deck. What is the probability that: 1.They are all red ? 2.At least one is black ? 3.They are.
1 Lecture 2 Control Structures: Part 1 Selection: else / if and switch.
StructureStructure. Outline Introduction Structure Definitions Initializing Structures Accessing Members of Structures Using Structures with Functions.
Chapter 11: Graphing. Bar Charts Pie Charts Line Graphs.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Arrangements and Selections (and how they may be counted)
Roots, Radicals, and Root Functions
The if…else Selection Statement
Equations of Circles.
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
Chapter 7 - Pointers Outline 7.1 Introduction
Chapter 2 Elementary Programming
Chapter 2 Equations and Inequalities in One Variable
Solving a Linear Equation
Equations of Circles.
11/7/16 Entry 173 – Objective I will review and continue developing my understanding of uniform probability models, including the complement of an event.
The Addition Rule.
Chapter 7 - Pointers Outline 7.1 Introduction
4-3 Standard Form Goal: Write a linear equation in standard form.
Section 2 – CSE341 Patrick Larson, Spring 2013.
AND.
Probability.
Section 2 – CSE341 Konstantin Weitz.
Module 5 Topic D.
Equations of Circles.
Chapter 4: Decision Structures and Boolean Logic
6.1 to 6.3 Solving Linear Inequalities
Lesson 2-4: Solving Inequalities
Circles Objective: Students will determine how the distance formula relates to the equation of a circle. Students will be able to get the equation of.
Strong’s GMAS Review, Week 5, Problems 4 - 5
Solving Equations with Variables on Both Sides
Changing Forms of Circles
JavaScript conditional
Lecture Notes – Week 2 Lecture-2
Relational Operators.
Standard Equation of a Circle Definition of a Circle
Section 12.2 Theoretical Probability
Section 12.2 Theoretical Probability
Inequalities and their Graphs
EOC REVIEW Question of the Day.
Algebra 2/Trig – Unit 8 Review Name: ________________________
Chapter 4: Decision Structures and Boolean Logic
1.3:Solving and Graphing Linear Inequalities
Variables and Constants
Standard Equation of a Circle Definition of a Circle
Section 12.2 Theoretical Probability
P(softball) = P(not a baseball) = P(golf ball) = A box contains 3 tennis balls, 7 softballs, and 11 baseballs. One ball is chosen at random. Find.
Chapter Equations of Circles.
Lesson Evaluating and Simplifying Expressions
Week #3 Quiz and Do Now.
Agenda Warmup Lesson 2.4 (String concatenation, primitive types, etc)
Presentation transcript:

Chapter 3 Practice

Practice with if statement Write an if statement that assigns 0 to x when y is equal to 20. Write an if statement that multiply salary by 1.5 if hours is greater than 40. Write an if statement that assigns 30000 to fine if boolean variable add_swap is true. Write an if statement that assigns 0 to b and 1 to c if a is less than 10

Practice with if statement Write an if statement that displays “Has dollar sign” if String variable s contains the character ‘$’. Write an if-else statement that assigns 20 to y if x is greater than 100. Otherwise, it assigns 0 to y. Write an if-else statement that assigns 1 to x when y is equal to 100. Otherwise, it assigns 0 to x. Write an if-else statement that assigns 0.1 to commision unless sales is greater than or equal to 50000, in which case it assigns 0.2 to commission. Write an if-else statement that assigns 0 to b and assigns 1 to c if a is less than 10. Otherwise, it assigns -99 to b and 0 to c.

Practice with boolean expression One runner runs d1 meters in t1 seconds, another runner runs d2 meters in t2 seconds. Declare a boolean variable isFaster that has value true if the first runner runs faster than the second. Given 3 integers a, b and c. Declare a boolean variable isTriangle that has value true if a, b, c can be the lengths of 3 sides of a triangle. Given a circle with center at (0, 0) and radius r, and given a point (a, b). Declare a boolean variable isInside that has value true if the point (a, b) is inside the circle. Given a circle with center at (0, 0) and radius r, and 3 integer coefficients a, b, c of equation of a line ax + by + c = 0. Declare a boolean variable isTangent that has value true if the line ax + by + c = 0 touches the circle at exactly one point.

Practice with switch statement Write a switch statement for variable ch of type char, based on its value as below: ch=‘A’: diplays “Excellent” ch=‘B’: diplays “Very Good” ch=‘C’: diplays “Good” ch=‘D’: diplays “Fair” ch=‘F’: diplays “Fail” Otherwise: displays “Not a grade”

Standard 52-card Deck Heart Queen DiamondKing Heart Club DiamondJack Spade Heart Ace

Practice with switch statement A deck has 52 cards, numbered from 0 to 51 using the following way: Heart: Ace  King, numbered from 0 to 12. Diamond: Ace  King, numbered from 13 to 25. Club: Ace  King, numbered from 26 to 38. Spade: Ace  King, numbered from 39 to 51. Write a program that reads a number from 0 to 51, then displays the name of card. Example: 11  Heart Ten, 45  Spade Five, 38  Club Jack