Chapter 4: Problem 14
What is the difference between preincrementing and postincrementing a variable?
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 14
What is the difference between preincrementing and postincrementing a variable?
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 freeDescribe the two ways in which control statements can be combined.
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.]
Develop 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.
Write Java statements to accomplish each of the following tasks: a) Use one statement to assign the sum of \(x\) and \(y\) to \(z,\) then increment \(x\) by 1 b) Test whether variable count is greater than \(10 .\) If it is, print "Count is greater than \(10 "\) c) Use one statement to decrement the variable \(x\) by 1 , then subtract it from variable total and store the result in variable total. d) Calculate the remainder after \(q\) is divided by divisor, and assign the result to q. Write this statement in two different ways.
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?
What do you think about this solution?
We value your feedback to improve our textbook solutions.