Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Exercise 3 Exercise #3 Due: Tuesday, February 5th. Exercise to practice using if statements. Credit limits Develop a Java application that will determine whether any of several department-store customers has exceeded the credit limit on a charge account. For each customer, the following facts are available: account number balance at the beginning of the month total of all items charged by the customer this month total of all credits applied to the customer's account this month allowed credit limit. Requirements The program should input all of these facts as integers, calculate the new balance (= beginning balance + charges - credits), display the new balance and determine whether the new balance exceeds the customer's credit limit. For those customers whose credit limit is exceeded, the program should display the message "Credit limit exceeded". Template: Credit.java Sample run 1: (user input underlined) Enter Account Number (or -1 to quit): 1 Enter Balance: 100 Enter Charges: 80 Enter Credits: 25 Enter Credit Limit: 200 New balance is 155 Enter Account Number (or -1 to quit): 2 Enter Balance: 450 Enter Charges: 240 Enter Credits: 300 Enter Credit Limit: 1000 New balance is 390 Enter Account Number (or -1 to quit): 3 Enter Balance: 500 Enter Charges: 300 Enter Credits: 125 Enter Credit Limit: 400 New balance is 675 Credit limit exceeded Enter Account Number (or -1 to quit): -1 Problem-solving tips There are five input values required. But the account number must be input before the loop in order to test whether it is equal to the sentinel value. So there should be six input statements, five in the loop and one before it. Use the formula given in the problem description to compute the new balance. Use an if statement to determine whether newBalance is larger than the customer's creditLimit. If so, indicate that the credit limit was exceeded. Write out your algorithms in pseudocode before writing any code. Be sure to follow the spacing and indentation conventions mentioned in the text. If you have any questions as you proceed, ask your lab instructor for assistance. Palindromes (Optional) - Extra challenge question 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 is a palindrome. If the number is not five digits long, display an error message and allow the user to enter a new value. Template: Palindrome.java Sample run 1: (user input underlined) Enter a 5-digit number: 1234 Number must be 5 digits Enter a 5-digit number: 123456 Number must be 5 digits Enter a 5-digit number: 54345 54345 is a palindrome!!! Enter a 5-digit number: 12345 12345 is NOT a palindrome!!! Problem-solving tips Determine the number of digits in the value input by the user and assign the result to digits. Use a while loop to determine whether the user input contains the proper number of digits. In the condition, determine whether digits is equal to five. If not, input a new value from the user and determine whether the new value contains the proper number of digits. When the number of digits is five, the loop should terminate. Use division and remainder calculations to obtain the separate digits. For a five-digit number to be a palindrome, the first and fifth digits must be the same and the second and fourth digits must be the same. Be sure to follow the spacing and indentation conventions mentioned in the text. If you have any questions as you proceed, ask for assistance. General Requirements When you write source code, it should be readable and well-documented. See the link Style Guidelines for further instructions on this topic Compiling and testing Compilation instructions for various environments are on the course web site, under the heading "Compilers and Compiling Help". These include instructions for building projects in both NetBeans and Eclipse, as well as compiling from the command line on your CS account or from the DOS prompt. Make sure to test your program with a variety of different inputs. The Sample Runs above are just that -- examples, only. Never hard-code your programs to work for only one or two test cases. Your program should work and calculate the correct results for any set of valid inputs. Submitting: Program submissions should be done by using the web site http://cgs3416.swzinc.org. Add the file(s) Credit.java and Palindrome.java (optional) to your submission. Do not send program submissions through e-mail -- e-mail attachments will not be accepted as valid submissions. General Advice - always keep an untouched copy of your finished homework files on your computer science account, or e-mail a copy of your finished files (before the due date) to your own FSU e-mail account. This way, these files will have a time-stamp which will show when they were last worked on (a timestamp from the CS servers, or a time stamp on the FSU e-mail) and will serve as a backup in case you ever have problems with submitting files. My advice is to do this for ALL programs. For Ex #3, submit only the following file: Credit.java Palindrome.java (optional) Make sure your filenames are these exact name(s), and do not submit the Driver.java file (or any other main program you might create for testing purposes).