COSC 111 Lecture Notes - Lecture 8: Divisor

90 views2 pages
Verified Note

Document Summary

Converting strings and numbers using parse method chapter 4. String s1= "5", s2 = "1. 4"; int n = integer. parseint(s1); //this converts string "5" into the number 5 double m = double. parsedouble(s2); //this is just an addition of 5 + 1. 4 = 6. 4. Converting numbers to strings int x = 9; //this converts the number 9 into a string. Formatting output using printf int age = 20; System. out. println("john is " + age + " years old. System. out. printf("john is %d years old. \n", age); int n1 = 7, n2 = 9; System. out. println("my sisters are " + n1 +" and " + n2); System. out. printf("my sisters are %-5d and %3d", n1, n2); chapter 3: selection public static void main(string[] args) { import java. util. scanner; public class selection { System. out. print("enter an integer: "); int n = in. nextint(); //if n is multiple of 5, print hifive if(n%5 == 0) //if n is multiple of 2, print hieven if(n%2 == 0) {

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents