Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java's loops. Convert Program ? Write a program that will convert a decimal number to octal. To convert a number, use the approach discussed in

Java's loops.

  1. Convert Program ? Write a program that will convert a decimal number to octal. To convert a number, use the approach discussed in lab where we keep dividing by the base using remainders to generate the conversion. You may not use the Integer.toOctalString method. You must use loops to compute the octal representation. The following example illustrates the messages to use to read data and to display results:
  2.             Enter decimal number: 10
  3.             Octal value: 12

       

  1. ThrowDie Program ? Write a program that simulates throwing a die n times. The program will read the number of times to throw the die and display the throws. Each throw is represented by 9 characters where we use 0 or . (see sample run below). To generate random values, you need to create a random object with a seed value that corresponds to the number of dies to throw. Use the method nextInt (with 6 as the argument) in order to generate integer random values between 0 and 5; just add 1 to the result to generate the die face. The following example illustrates the messages to use to read data and to display results.
  2. How many times to throw a die?: 14
  3. Throw #1
  4. 0.0
  5. 0.0
  6. 0.0
  7. Throw #2
  8. ...
  9.  0
  10. ...
  11. Throw #3
  12. 0.0
  13. 0.0
  14. 0.0
  15. Throw #4
  16. 0.0
  17. 0.0
  18. 0.0
  19. Throw #5
  20. 0..
  21. .0.
  22. ..0
  23. Throw #6
  24. 0..
  25. .0.
  26. ..0
  27. Throw #7
  28. 0..
  29. .0.
  30. ..0
  31. Throw #8
  32. 0.0
  33. 0.0
  34. 0.0
  35. Throw #9
  36. 0..
  37. ...
  38. ..0
  39. Throw #10
  40. 0.0
  41. ...
  42. 0.0
  43. Throw #11
  44. 0.0
  45. ...
  46. 0.0
  47. Throw #12
  48. 0.0
  49. 0.0
  50. 0.0
  51. Throw #13
  52. 0.0
  53. .0.
  54. 0.0
  55. Throw #14
  56. 0..
  57. .0.
  58. ..0
  59.  

       

  1. Access Program ? Write a program that reads a string (password) and a number. The program will keep asking the user for a password and number as long as the user does not provide the expected values ("milkyway" and 1847, respectively), and as long as the user has not exhausted the maximum number of attempts . In addition, the program will stop asking for data if the word "quit" is provided as a password value (in this case, the program will not read the number). The program will print the message "Wrong credentials" when an invalid password or number (or both) is provided. If the user eventually provides the correct credentials the message "Access Granted" will be displayed; otherwise the message "Access Denied" will be generated. The following example illustrates the messages to use to read data and to display results.
  2.             Enter password: milkyway
  3.             Enter number: 10
  4.             Wrong credentials
  5.             Enter password: tomato
  6.             Enter number: 1847
  7.             Wrong credentials
  8.             Enter password: milkyway
  9.             Enter number: 1847

            Access Granted












Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

App Inventor

Authors: David Wolber, Hal Abelson

1st Edition

1449397484, 9781449397487

More Books

Students also viewed these Programming questions

Question

What is a safe edge on a file?

Answered: 1 week ago

Question

19) How are cost drivers selected in activity-based costing systems

Answered: 1 week ago