CS1011
Homework
Enter three letters: aim The three letters entered are in alphabetical order. Enter three letters: toe The three letters entered are in reverse alphabetical order. Enter three letters: bye The three letters entered are not in order.### switch Suppose you are making a game that needs to control a character on the screen. The following key mappings should be used:
j down k up h left### Rewrite for loop as while loop Rewrite the following `for` loop as a `while` loop: ``` for(int i=1; i<10; i=i+1) { System.out.println(i + "^2 = " + i*i); } ``` ### Loops [video solution](../se1011f16/lectures/1011-3-3-4.mp4) Write a program that asks the user to enter a word. The program should indicate whether the letters in the word are in alphabetical order, reverse alphabetical order, or neither. Sample interaction should look like this:
Enter a word: abhors The letters entered are in alphabetical order. Enter a word: soon The letters entered are in reverse alphabetical order. Enter a word: typical The letters entered are not in order.### do while loop Write a program that asks the user to enter something. If the user just hits enter without entering any characters first, the program should ask the user again (repeatedly, until the user enters something). The program should then end. Hint: use `nextLine()`. ### Loops Ask the user to enter two integer values: height and width. Your program should then generate a box of
Please enter the height: 3 Please enter the width: 5 ***** ***** *****### Loops Ask the user to enter a name and print all of the letters in the name, one per line. Include line numbers for the lines. Sample interaction may look like this:
Enter a name: Chris Letters: 1. C 2. h 3. r 4. i 5. s### Loops [video solution](../se1011f16/lectures/1011-3-3-8.mp4) Ask the user to enter as many positive integers as the user wants followed by a non-positive integer. The program should then display the sum of all positive values that are divisible by 3. Sample interaction may look like this:
Enter a bunch of positive integers followed by a non-positive integer: 1 2 3 4 5 6 7 8 9 10 11 18 0 Answer: 36### Loops Suppose you are making a game that needs to control a character on the screen. The following key mappings should be used:
jjlllk down down right right right up### Loops Rewrite the program in the previous exercise so that the output matches the sample below.
jjlllk 2 down 3 right 1 up## Week 5 (doable by Friday of week 5) * Write a paragraph or code snipet that demonstrates attainment of each Week 4 [outcome](Outcomes) * Write a paragraph or code snipet that demonstrates attainment of each Week 5 [outcome](Outcomes) * Exercise: 5.3, 5.7, 5.8 ## Week 6 (doable by Friday of week 6) * Write a paragraph or code snipet that demonstrates attainment of each Week 6 [outcome](Outcomes) * Exercise: 6.6, 6.10, 6.11, 6.13, 7.2 * In the `Student` class developed in lecture, add an instance variable with [`LocalDate date`](http://docs.oracle.com/javase/8/docs/api/java/time/LocalDate.html). Hint: `java.time.temporal.ChronoUnit.YEARS.between(a, b);` returns the number of years between two `LocalDate`s. * Study [this Taylorial page](https://taylorial.com/cs1011/Classes.htm) and prepare at least one question to ask your instructor. (Be prepared to ask Monday of week 7) ## Week 7 (doable by Thursday of week 7) * Write a paragraph or code snipet that demonstrates attainment of each Week 7 [outcome](Outcomes) * Implement a class that represents a dog. The class should keep track of the dogs color, weight, and age. * Write an instance method for the `Dog` class, `swap(Dog that)`, that swaps the contents of the current dog with the dog passed to the method. * Exercise: 7.2, 7.7 ## Week 8 (doable by on Tuesday of week 8) * Write a paragraph or code snipet that demonstrates attainment of each Week 8 [outcome](Outcomes) * Exercise: 9.9 * Implement `calculateTermQuizScore()` that accepts an array of `int`s as an argument and returns a `double` representing the quiz grade for the quarter. ## Week 9 (doable by Friday of week 9) * Exercise: 10.7, 10.9, 10.10 * [CodingBat: lucky13](http://www.codingbat.com/prob/p194525) * [CodingBat: sum28](http://www.codingbat.com/prob/p199612) * [CodingBat: centeredAverage](http://www.codingbat.com/prob/p136585) * The above centeredAverage problem with an ArrayList instead. (`public int centeredAverage(ArrayList