Chapter 4: Problem 12
Describe the two ways in which control statements can be combined.
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.
Chapter 4: Problem 12
Describe the two ways in which control statements can be combined.
These are the key concepts you need to understand to accurately answer the question.
All the tools & learning materials you need for study success - in one app.
Get started for freeDevelop a Java application that determines whether any of several department- store customers has exceeded the credit limit on a charge account. For each customer, the following facts are available: a) account number b) balance at the beginning of the month c) total of all items charged by the customer this month d) total of all credits applied to the customer's account this month e) allowed credit limit.
The explosive growth of Internet communications and data storage on Internet- connected computers has greatly increased privacy concerns. The field of cryptography is concerned with coding data to make it difficult (and hopefully-with the most advanced schemes - impossible) for unauthorized users to read. In this exercise you'll investigate a simple scheme for encrypting and decrypting data. A company that wants to send data over the Internet has asked you to write a program that will encrypt it so that it may be transmitted more securely. All the data is transmitted as four-digit integers. Your application should read a four-digit integer entered by the user and encrypt it as follows: Replace each digit with the result of adding 7 to the digit and getting the remainder after dividing the new value by \(10 .\) Then swap the first digit with the third, and swap the second digit with the fourth. Then print the encrypted integer. Write a separate application that inputs an encrypted four-digit integer and decrypts it (by reversing the encryption scheme) to form the original number. [Optional reading project: Research "public key cryptography" in general and the PGP (Pretty Good Privacy) specific public key scheme. You may also want to investigate the RSA scheme, which is widely used in industrial-strength applications.]
Explain what happens when a Java program attempts to divide one integer by another. What happens to the fractional part of the calculation? How can you avoid that outcome?
State whether each of the following is true or false. If false, explain why. a) An algorithm is a procedure for solving a problem in terms of the actions to execute and the order in which they exccute. b) A set of statements contained within a pair of parentheses is called a block. c) A selection statement specifies that an action is to be repeated while some condition remains true. d) \(A\) nested control statement appears in the body of another control statement. e) Java provides the arithmetic compound assignment operators \(+=,-=, *=, /=\) and \(\mathscr{X}=\) for abbreviating assignment expressions. f) The primitive types (boolean, char, byte, short, int, long, float and double) are portable across only Windows platforms. g) Specifying the order in which statements execute in a program is called program control. h) The unary cast operator (double) creates a temporary integer copy of its operand. i) Instance variables of type boolean are given the value true by default. j) Pseudocode helps you think out a program before attempting to write it in a programming language.
A palindrome is a sequence of characters that reads the same backward as forward. For example, each of the following five-digit integers is a palindrome: 12321,55555,45554 and \(11611 .\) Write an application that reads in a five-digit integer and determines whether it's a palindrome. If the number is not five digits long, display an error message and allow the user to enter a new value.
What do you think about this solution?
We value your feedback to improve our textbook solutions.