|
-
Help converting doubles to integers...
I'm currently in a Java programming class and stuck on an assginment.
The assignment asks me to do the following:
Write a program that:
a. Prompts the user to input five decimal numbers.
b. Prints the five decimal numbers.
c. Converts each decimal number to the nearest integer.
d. Adds the five integers.
e. Prints the sum and average of the integers.
I did part a and b with no problem but theres nothing in the chapter we're covering that talks about converting decimal numbers to the nearest integer (i.e. if it's 3.3 round it down to 3 and if it's 3.6 round it up to 4). If I can figure out part c then I can finish the rest of it.
There is a small section on type conversion (casting) in the chapter but it only talks about how it works, no examples of code or how to use casting.
Any help is appreciated
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks