CS 0401 Lecture Notes - Lecture 6: Data Validation, Polskie Radio Program I

58 views11 pages

Document Summary

Comparing string objects, formatting output, switch statement and loops. String variables contain memory addresses of string objects. String name2 = mary : if (name1 == name2, if (name1. equals(name2)) Add some code so that if the user s product is in the inclusive range 0 to 100, your program will print the message: Your product is outside of the range [0,100]. Stringreference. compareto(otherstring) returns a negative value if calling string is less than argument string returns 0 if the two strings are equal returns a positive value if the calling string is greater than the argument string. # - display a digit if one is present; otherwise, no digit is display. 0 display a digit if one is present; otherwise, display a 0. Another method of formatting output is to use the printf method: 14 int dogs = 2; int cats = 4; System. out. printf( we have %d dogs and %d cats. \n , dogs, cats);

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