SlideShare una empresa de Scribd logo
1 de 6
Complete a program that asks the user to enter a floating-point
number (either positive or negative).
The program repeats while the user enters ‘y’ to continue.
The program allows a user to enter either a lowercase or
uppercase character.
Use the ceil use the ( ), floor ( ), and abs ( ) methods to
determine the smallest whole number that is greater than or
equal to the number entered, the largest whole number that is
less than or equal to the number entered, and the absolute value
of the number given, respectively. Use the
toLowercase ( )
method to change a given character value to lowercase if the
value is an uppercase value.
Supply the missing code and import the correct packages for the
predefined methods used.
Following is a copy of the screen results that might appear after
running your program, depending on the data entered after all
the changes have been made. The text entered by the user
appears in bold.
Enter a float number and I will tell you:
the smallest whole number > = to the number,
the largest whole number < = to the number,
and the absolute value of the number.
5.4
The smallest home number greater than 5.4 is 6.0
The larger whole number less than 5.4 is 5.0
The absolute value of 5.4 is 5.4
Do you want to enter more data?
y/n
y
Enter a float number and I will tell you:
the smallest home number > = to the number,
the largest whole number < = to the number, an
and the absolute value of the number.
-8.8
The smallest whole number greater than -8.8 is -8.0
The largest whole number less than -8.8 is -9.0
The absolute value of -8.8 is 8.8
Do you want to enter more data?
y/n
n
Complete the following Java program, inserting comments,
package names, or calls to methods of the class Math after the
bold comments. For readability, leave them blank lines and
comments in place throughout the program. Save program as
NumbersFixed.java
to the device or location specified by your instructor. Compile,
execute, and test program. After executing your program, select
and copy everything that appears on your screen. Paste the
copied text into a comment block at the end of your program.
// Include comments to identify the writer of the code
// and to describe the program.
import
java.util,*;
// The following statement imports the Math class.
import
public class NumbersFixed
{
static Scanner console = new Scanner (System.in);
public static void main (String[ ] args)
{
double x;
String token;
char again = ‘y’;
while
(again = = ‘y’)
{
System.out.println(“ Enter a float number and I will “
+ “tell you:n”
+ “the smallest whole number > = to the number,n”
+ “the largest whole number < = to the number,n”
+ “and the absolute value of the number.n”);
x = console.nextDouble ( );
System.out.println(“nThe smallest whole number “
+ “greater than “
+
x
+
“ is
“
/ / Following is a method call to calculate the
/ / smallest whole number > = the input value.
+
+ “nThe largest whole number less than “
+
x
+” is “
/ / Following is a method call to calculate the
/ /largest whole number < = the input value.
+
+ “nThe absolute value of “
+
x
+
“ is “
/ / Following is a method call to calculate the
/ / absolute value of the input value.
+
+ “n” );
System.out.println( “Do you want to enter more data?”
+ “
y/n “);
token = console.next ( ) ;
again = token.charAt ( 0 ) ;
/ / The following statement converts the response
/ / character entered by the user to lowercase.
again =
}
}
}

Más contenido relacionado

Similar a Complete a program that asks the user to enter a floating-point numb.docx

Please help. C++ The program is an interactive program th.pdf
Please help. C++ The program is an interactive program th.pdfPlease help. C++ The program is an interactive program th.pdf
Please help. C++ The program is an interactive program th.pdffsenterprises
 
OverviewThis hands-on lab allows you to follow and experiment w.docx
OverviewThis hands-on lab allows you to follow and experiment w.docxOverviewThis hands-on lab allows you to follow and experiment w.docx
OverviewThis hands-on lab allows you to follow and experiment w.docxgerardkortney
 
Oop lab assignment 01
Oop lab assignment 01Oop lab assignment 01
Oop lab assignment 01Drjilesh
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfmayorothenguyenhob69
 
Programming basics
Programming basicsProgramming basics
Programming basicsillidari
 
Seminar 2 coding_principles
Seminar 2 coding_principlesSeminar 2 coding_principles
Seminar 2 coding_principlesmoduledesign
 
IN C++ PLEASE Topics Loops While statement Description Write.pdf
IN C++ PLEASE     Topics   Loops While statement   Description   Write.pdfIN C++ PLEASE     Topics   Loops While statement   Description   Write.pdf
IN C++ PLEASE Topics Loops While statement Description Write.pdfasdepartmantal
 
Introduction to Programming and QBasic Tutorial
Introduction to Programming and QBasic TutorialIntroduction to Programming and QBasic Tutorial
Introduction to Programming and QBasic Tutorialnhomz
 
In C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxIn C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxtristans3
 
Md university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newMd university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab neweyavagal
 
C++ Tutorial.docx
C++ Tutorial.docxC++ Tutorial.docx
C++ Tutorial.docxPinkiVats1
 
Seminar 2 coding_principles
Seminar 2 coding_principlesSeminar 2 coding_principles
Seminar 2 coding_principlesmoduledesign
 
Sample Program file class 11.pdf
Sample Program file class 11.pdfSample Program file class 11.pdf
Sample Program file class 11.pdfYashMirge2
 
Md university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newMd university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newLast7693
 
Md university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newMd university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newscottbrownnn
 

Similar a Complete a program that asks the user to enter a floating-point numb.docx (20)

C important questions
C important questionsC important questions
C important questions
 
Please help. C++ The program is an interactive program th.pdf
Please help. C++ The program is an interactive program th.pdfPlease help. C++ The program is an interactive program th.pdf
Please help. C++ The program is an interactive program th.pdf
 
OverviewThis hands-on lab allows you to follow and experiment w.docx
OverviewThis hands-on lab allows you to follow and experiment w.docxOverviewThis hands-on lab allows you to follow and experiment w.docx
OverviewThis hands-on lab allows you to follow and experiment w.docx
 
Oop lab assignment 01
Oop lab assignment 01Oop lab assignment 01
Oop lab assignment 01
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdf
 
Programming basics
Programming basicsProgramming basics
Programming basics
 
Seminar 2 coding_principles
Seminar 2 coding_principlesSeminar 2 coding_principles
Seminar 2 coding_principles
 
IN C++ PLEASE Topics Loops While statement Description Write.pdf
IN C++ PLEASE     Topics   Loops While statement   Description   Write.pdfIN C++ PLEASE     Topics   Loops While statement   Description   Write.pdf
IN C++ PLEASE Topics Loops While statement Description Write.pdf
 
Introduction to Programming and QBasic Tutorial
Introduction to Programming and QBasic TutorialIntroduction to Programming and QBasic Tutorial
Introduction to Programming and QBasic Tutorial
 
In C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxIn C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docx
 
Md university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newMd university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab new
 
C++ Tutorial.docx
C++ Tutorial.docxC++ Tutorial.docx
C++ Tutorial.docx
 
Seminar 2 coding_principles
Seminar 2 coding_principlesSeminar 2 coding_principles
Seminar 2 coding_principles
 
Sample Program file class 11.pdf
Sample Program file class 11.pdfSample Program file class 11.pdf
Sample Program file class 11.pdf
 
Input-output
Input-outputInput-output
Input-output
 
Md university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newMd university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab new
 
Md university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab newMd university cmis 102 week 4 hands on lab new
Md university cmis 102 week 4 hands on lab new
 
keyword
keywordkeyword
keyword
 
keyword
keywordkeyword
keyword
 
Loops in Python
Loops in PythonLoops in Python
Loops in Python
 

Más de luellaj

Complete the following comparison table between managerial and finan.docx
Complete the following comparison table between managerial and finan.docxComplete the following comparison table between managerial and finan.docx
Complete the following comparison table between managerial and finan.docxluellaj
 
Complete the following sentence stems....1. A special situat.docx
Complete the following sentence stems....1. A special situat.docxComplete the following sentence stems....1. A special situat.docx
Complete the following sentence stems....1. A special situat.docxluellaj
 
Complete the following question in 400 words with in-text citations .docx
Complete the following question in 400 words with in-text citations .docxComplete the following question in 400 words with in-text citations .docx
Complete the following question in 400 words with in-text citations .docxluellaj
 
Complete the following assignment in one MS word document Chapt.docx
Complete the following assignment in one MS word document Chapt.docxComplete the following assignment in one MS word document Chapt.docx
Complete the following assignment in one MS word document Chapt.docxluellaj
 
Complete the following assignment in one MS word documentChap.docx
Complete the following assignment in one MS word documentChap.docxComplete the following assignment in one MS word documentChap.docx
Complete the following assignment in one MS word documentChap.docxluellaj
 
Complete the following assignments in one MS word documentAns.docx
Complete the following assignments in one MS word documentAns.docxComplete the following assignments in one MS word documentAns.docx
Complete the following assignments in one MS word documentAns.docxluellaj
 
Complete the following assignment in one MS word document C.docx
Complete the following assignment in one MS word document C.docxComplete the following assignment in one MS word document C.docx
Complete the following assignment in one MS word document C.docxluellaj
 
Complete the following and submit for a gradeLab 1 Creating a .docx
Complete the following and submit for a gradeLab 1 Creating a .docxComplete the following and submit for a gradeLab 1 Creating a .docx
Complete the following and submit for a gradeLab 1 Creating a .docxluellaj
 
Complete the final 6-page APA Multicultural Panel assignment, due at.docx
Complete the final 6-page APA Multicultural Panel assignment, due at.docxComplete the final 6-page APA Multicultural Panel assignment, due at.docx
Complete the final 6-page APA Multicultural Panel assignment, due at.docxluellaj
 
Complete the external environmental scan for your organization (Xe.docx
Complete the external environmental scan for your organization (Xe.docxComplete the external environmental scan for your organization (Xe.docx
Complete the external environmental scan for your organization (Xe.docxluellaj
 
Complete the eleven sections (Sections I-XI) of the Progress Monit.docx
Complete the eleven sections (Sections I-XI) of the Progress Monit.docxComplete the eleven sections (Sections I-XI) of the Progress Monit.docx
Complete the eleven sections (Sections I-XI) of the Progress Monit.docxluellaj
 
Complete the Contract Plan Template to use a third party for the new.docx
Complete the Contract Plan Template to use a third party for the new.docxComplete the Contract Plan Template to use a third party for the new.docx
Complete the Contract Plan Template to use a third party for the new.docxluellaj
 
Complete the conversation with the appropriate forms of the verbs in.docx
Complete the conversation with the appropriate forms of the verbs in.docxComplete the conversation with the appropriate forms of the verbs in.docx
Complete the conversation with the appropriate forms of the verbs in.docxluellaj
 
Complete the Contributions to IO Psychology worksheet..docx
Complete the Contributions to IO Psychology worksheet..docxComplete the Contributions to IO Psychology worksheet..docx
Complete the Contributions to IO Psychology worksheet..docxluellaj
 
Complete the Cardiovascular Exemplar Table in its entirety. .docx
Complete the Cardiovascular Exemplar Table in its entirety. .docxComplete the Cardiovascular Exemplar Table in its entirety. .docx
Complete the Cardiovascular Exemplar Table in its entirety. .docxluellaj
 
Complete the attached Strategic Marketing Plan Template Part B.docx
Complete the attached Strategic Marketing Plan Template Part B.docxComplete the attached Strategic Marketing Plan Template Part B.docx
Complete the attached Strategic Marketing Plan Template Part B.docxluellaj
 
Complete Section C Research Support.Develop a research base for.docx
Complete Section C Research Support.Develop a research base for.docxComplete Section C Research Support.Develop a research base for.docx
Complete Section C Research Support.Develop a research base for.docxluellaj
 
Complete Table-1 (Joseph Farms, Inc., Cost and Revenue Data), either.docx
Complete Table-1 (Joseph Farms, Inc., Cost and Revenue Data), either.docxComplete Table-1 (Joseph Farms, Inc., Cost and Revenue Data), either.docx
Complete Table-1 (Joseph Farms, Inc., Cost and Revenue Data), either.docxluellaj
 
Complete Problem Museum Gala on pg. 465-466.Complete Question.docx
Complete Problem Museum Gala on pg. 465-466.Complete Question.docxComplete Problem Museum Gala on pg. 465-466.Complete Question.docx
Complete Problem Museum Gala on pg. 465-466.Complete Question.docxluellaj
 
Complete Plan (20) Prepare a 1300 word paper in which you recomme.docx
Complete Plan (20) Prepare a 1300 word paper in which you recomme.docxComplete Plan (20) Prepare a 1300 word paper in which you recomme.docx
Complete Plan (20) Prepare a 1300 word paper in which you recomme.docxluellaj
 

Más de luellaj (20)

Complete the following comparison table between managerial and finan.docx
Complete the following comparison table between managerial and finan.docxComplete the following comparison table between managerial and finan.docx
Complete the following comparison table between managerial and finan.docx
 
Complete the following sentence stems....1. A special situat.docx
Complete the following sentence stems....1. A special situat.docxComplete the following sentence stems....1. A special situat.docx
Complete the following sentence stems....1. A special situat.docx
 
Complete the following question in 400 words with in-text citations .docx
Complete the following question in 400 words with in-text citations .docxComplete the following question in 400 words with in-text citations .docx
Complete the following question in 400 words with in-text citations .docx
 
Complete the following assignment in one MS word document Chapt.docx
Complete the following assignment in one MS word document Chapt.docxComplete the following assignment in one MS word document Chapt.docx
Complete the following assignment in one MS word document Chapt.docx
 
Complete the following assignment in one MS word documentChap.docx
Complete the following assignment in one MS word documentChap.docxComplete the following assignment in one MS word documentChap.docx
Complete the following assignment in one MS word documentChap.docx
 
Complete the following assignments in one MS word documentAns.docx
Complete the following assignments in one MS word documentAns.docxComplete the following assignments in one MS word documentAns.docx
Complete the following assignments in one MS word documentAns.docx
 
Complete the following assignment in one MS word document C.docx
Complete the following assignment in one MS word document C.docxComplete the following assignment in one MS word document C.docx
Complete the following assignment in one MS word document C.docx
 
Complete the following and submit for a gradeLab 1 Creating a .docx
Complete the following and submit for a gradeLab 1 Creating a .docxComplete the following and submit for a gradeLab 1 Creating a .docx
Complete the following and submit for a gradeLab 1 Creating a .docx
 
Complete the final 6-page APA Multicultural Panel assignment, due at.docx
Complete the final 6-page APA Multicultural Panel assignment, due at.docxComplete the final 6-page APA Multicultural Panel assignment, due at.docx
Complete the final 6-page APA Multicultural Panel assignment, due at.docx
 
Complete the external environmental scan for your organization (Xe.docx
Complete the external environmental scan for your organization (Xe.docxComplete the external environmental scan for your organization (Xe.docx
Complete the external environmental scan for your organization (Xe.docx
 
Complete the eleven sections (Sections I-XI) of the Progress Monit.docx
Complete the eleven sections (Sections I-XI) of the Progress Monit.docxComplete the eleven sections (Sections I-XI) of the Progress Monit.docx
Complete the eleven sections (Sections I-XI) of the Progress Monit.docx
 
Complete the Contract Plan Template to use a third party for the new.docx
Complete the Contract Plan Template to use a third party for the new.docxComplete the Contract Plan Template to use a third party for the new.docx
Complete the Contract Plan Template to use a third party for the new.docx
 
Complete the conversation with the appropriate forms of the verbs in.docx
Complete the conversation with the appropriate forms of the verbs in.docxComplete the conversation with the appropriate forms of the verbs in.docx
Complete the conversation with the appropriate forms of the verbs in.docx
 
Complete the Contributions to IO Psychology worksheet..docx
Complete the Contributions to IO Psychology worksheet..docxComplete the Contributions to IO Psychology worksheet..docx
Complete the Contributions to IO Psychology worksheet..docx
 
Complete the Cardiovascular Exemplar Table in its entirety. .docx
Complete the Cardiovascular Exemplar Table in its entirety. .docxComplete the Cardiovascular Exemplar Table in its entirety. .docx
Complete the Cardiovascular Exemplar Table in its entirety. .docx
 
Complete the attached Strategic Marketing Plan Template Part B.docx
Complete the attached Strategic Marketing Plan Template Part B.docxComplete the attached Strategic Marketing Plan Template Part B.docx
Complete the attached Strategic Marketing Plan Template Part B.docx
 
Complete Section C Research Support.Develop a research base for.docx
Complete Section C Research Support.Develop a research base for.docxComplete Section C Research Support.Develop a research base for.docx
Complete Section C Research Support.Develop a research base for.docx
 
Complete Table-1 (Joseph Farms, Inc., Cost and Revenue Data), either.docx
Complete Table-1 (Joseph Farms, Inc., Cost and Revenue Data), either.docxComplete Table-1 (Joseph Farms, Inc., Cost and Revenue Data), either.docx
Complete Table-1 (Joseph Farms, Inc., Cost and Revenue Data), either.docx
 
Complete Problem Museum Gala on pg. 465-466.Complete Question.docx
Complete Problem Museum Gala on pg. 465-466.Complete Question.docxComplete Problem Museum Gala on pg. 465-466.Complete Question.docx
Complete Problem Museum Gala on pg. 465-466.Complete Question.docx
 
Complete Plan (20) Prepare a 1300 word paper in which you recomme.docx
Complete Plan (20) Prepare a 1300 word paper in which you recomme.docxComplete Plan (20) Prepare a 1300 word paper in which you recomme.docx
Complete Plan (20) Prepare a 1300 word paper in which you recomme.docx
 

Último

Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 

Último (20)

Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 

Complete a program that asks the user to enter a floating-point numb.docx

  • 1. Complete a program that asks the user to enter a floating-point number (either positive or negative). The program repeats while the user enters ‘y’ to continue. The program allows a user to enter either a lowercase or uppercase character. Use the ceil use the ( ), floor ( ), and abs ( ) methods to determine the smallest whole number that is greater than or equal to the number entered, the largest whole number that is less than or equal to the number entered, and the absolute value of the number given, respectively. Use the toLowercase ( ) method to change a given character value to lowercase if the value is an uppercase value. Supply the missing code and import the correct packages for the predefined methods used. Following is a copy of the screen results that might appear after running your program, depending on the data entered after all the changes have been made. The text entered by the user appears in bold. Enter a float number and I will tell you: the smallest whole number > = to the number, the largest whole number < = to the number, and the absolute value of the number. 5.4 The smallest home number greater than 5.4 is 6.0 The larger whole number less than 5.4 is 5.0 The absolute value of 5.4 is 5.4
  • 2. Do you want to enter more data? y/n y Enter a float number and I will tell you: the smallest home number > = to the number, the largest whole number < = to the number, an and the absolute value of the number. -8.8 The smallest whole number greater than -8.8 is -8.0 The largest whole number less than -8.8 is -9.0 The absolute value of -8.8 is 8.8 Do you want to enter more data? y/n n Complete the following Java program, inserting comments, package names, or calls to methods of the class Math after the bold comments. For readability, leave them blank lines and comments in place throughout the program. Save program as NumbersFixed.java to the device or location specified by your instructor. Compile, execute, and test program. After executing your program, select and copy everything that appears on your screen. Paste the copied text into a comment block at the end of your program. // Include comments to identify the writer of the code // and to describe the program. import java.util,*; // The following statement imports the Math class.
  • 3. import public class NumbersFixed { static Scanner console = new Scanner (System.in); public static void main (String[ ] args) { double x; String token; char again = ‘y’; while (again = = ‘y’) { System.out.println(“ Enter a float number and I will “ + “tell you:n” + “the smallest whole number > = to the number,n”
  • 4. + “the largest whole number < = to the number,n” + “and the absolute value of the number.n”); x = console.nextDouble ( ); System.out.println(“nThe smallest whole number “ + “greater than “ + x + “ is “ / / Following is a method call to calculate the / / smallest whole number > = the input value. + + “nThe largest whole number less than “ +
  • 5. x +” is “ / / Following is a method call to calculate the / /largest whole number < = the input value. + + “nThe absolute value of “ + x + “ is “ / / Following is a method call to calculate the / / absolute value of the input value. + + “n” );
  • 6. System.out.println( “Do you want to enter more data?” + “ y/n “); token = console.next ( ) ; again = token.charAt ( 0 ) ; / / The following statement converts the response / / character entered by the user to lowercase. again = } } }