JAVA PROGRAM(LL)+MINDTAP (1 TERM) V2.0
9th Edition
ISBN: 9780357616673
Author: FARRELL
Publisher: CENGAGE L
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 6, Problem 3PE
Explanation of Solution
Program:
File name: “Factorials.java”
//Define a class named Factorials
public class Factorials
{
//Define the main method
public static void main(String []args)
{
//Declare a variable
int numb;
/*Run the loop 10 times using the variable 'i' which represents
each of the numbers from 1 to 10*/
for(int i=1;i<=10;i++)
{
/*Call the fact() while passing the value of i,
collect the returned value in variable 'numb' */
numb = fact(i);
//Print the factorial value of each number
System...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
A Java Practical Assignments.pdf - Adobe Acrobat Pro DC (32-bit)
File Edit View E-Sign Window Help
Home
Tools
Java Practical Assig. x
Sign In
1 /1
139%
Java Practical Assignments
1. Write an application that throws and catches an ArithmeticException when you attempt to take the
square root of a negative value. Prompt the user for an input value and try the Math.sqrt() method on
it. The application either displays the square root or catches the thrown Exception and displays an
appropriate message.
2. Create a program that allows a user to input customer records (ID number, first name, last name,
and balance owed) and save each record to a file.
3. Write an application for Limpopo's Car Care Shop that shows a user a list of available services: oil
change, tire rotation, battery check, or brake inspection. Allow the user to enter a string that
corresponds to one of the options, and display the option and its price as R250, R220, R150, or R50,
accordingly. Display an error message if the…
Programming in C#:
Write a console-based application that displays every perfect number from 1 through 10000. A number is perfect if it equals the sum of all the smaller positive integers that divide evenly into it. For example, 6 is perfect because 1, 2, and 3 divide evenly into it and their sum is 6. Use format strings(field size 8, right alignment) to show all perfect numbers. Display the results as seen below.
6
28
496
8128
Write an application that displays the factorial for every integer value from 1 to 10. A factorial of a number is the product of that number multiplied by each positive -integer lower than it. For example, 4 factorial is 4 * 3 * 2 * 1, or 24. Save the file as Factorials.cpp.
Chapter 6 Solutions
JAVA PROGRAM(LL)+MINDTAP (1 TERM) V2.0
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- YOU HAVE TWO TAKE TWO INTS, EACH IN THE RANGE 10.99, PRINT 'POSSIBLE' IF THERE IS A DIGIT THAT APPEARS IN BOTH NUMBERS. PROGRAMMING LANGUAGE: JAVA.arrow_forwardTrainers at Tom's Athletic Club are encouraged to enroll new members. Write an application that extracts the names of Trainers and groups them based on the number of new members each trainer has enrolled this year. Output is the number of trainers who have enrolled 0 to 5 members, 6 to 12 members, 13 to 20 members, and more than 20 members. Give their names as well as the number of members they have enrolled. Use this list of trainers: {"Jake Butt", "Ziggy Hood", "Hroniss Grasu", "Vontaze Burfict", "Jaquiski Tartt","Ndamukong Suh", "Thurston Armbrister", "Captain Munnerlyn", "Barkevious Mingo", "Ha Ha Clinton-Dix","Mister Alexander", "BenJarvus Green-Ellis", "Richie Incognito", "Champ Bailey", "Captain Munnerlyn","Mike Kafka", "Ras-I Dowling", "Bryan Anger", "D'Brickashaw Ferguson", "Rex Hadnot","Sage Rosenfels", "Robert Griffin III", "Sav Rocca", "Chad Ochocinco", "Brett Rypien"} Use this list of the number of members each trainer has enrolled: {3, 9, 13, 26, 23,19, 15, 13, 17,…arrow_forwardWrite an application that counts by five from 5 through 500 inclusive and that starts a new line after every multiple of 50 (50,100,150 and so on).Save the file as CountByAnything.javaarrow_forward
- Create an application for generating lottery tickets of random numbers. Each lottery ticket has a fixed count of numbers to be played with each number selected being within a given range. For example, when the range of numbers is 1 through 100, and 5 numbers are to be played, the lottery ticket will be composed of 5 unique values between 1 and 100. The values are selected at random. The main function is responsible for obtaining the upper range of the numbers and the count of numbers to be played from the end user. The count of numbers must be less than the upper range. The main function will call the generateLotto function to generate the lottery ticket and then call the displayTicket function to display the resulting lottery ticket. Any number of lottery tickets may be generated. The generateLotto function should accept two parameters. The first should be the upper range for the numbers while the second parameter represents a count of the numbers to be played. For example,…arrow_forwardwrite an application that reads English-Language phrase and encodes it into morse code. also write an application that reads a phrase in morse code and converts it into the English-Language equivalent . Use one blank between each Morse-code letter and three blanks between each Morse-coded word.arrow_forwardCreate an application for generating lottery tickets of random numbers. Each lottery ticket has a fixed count of numbers to be played with each number selected being within a given range. For example, when the range of numbers is 1 through 100, and 5 numbers are to be played, the lottery ticket will be composed of 5 unique values between 1 and 100. The values are selected at random. The main function is responsible for obtaining the upper range of the numbers and the count of numbers to be played from the end user. The count of numbers must be less than the upper range. The main function will call the generateLotto function to generate the lottery ticket and then call the displayTicket function to display the resulting lottery ticket. Any number of lottery tickets may be generated. The generateLotto function should accept two parameters. The first should be the upper range for the numbers while the second parameter represents a count of the numbers to be played. For example,…arrow_forward
- Create an application for generating lottery tickets of random numbers. Each lottery ticket has a fixed count of numbers to be played with each number selected being within a given range. For example, when the range of numbers is 1 through 100, and 5 numbers are to be played, the lottery ticket will be composed of 5 unique values between 1 and 100. The values are selected at random. The main function is responsible for obtaining the upper range of the numbers and the count of numbers to be played from the end user. The count of numbers must be less than the upper range. The main function will call the generateLotto function to generate the lottery ticket and then call the displayTicket function to display the resulting lottery ticket. Any number of lottery tickets may be generated. The generateLotto function should accept two parameters. The first should be the upper range for the numbers while the second parameter represents a count of the numbers to be played. For example,…arrow_forwardThis is the question: Write an application that displays the factorial for every integer value from 1 to 10. A factorial of a number is the product of that number multiplied by each positive integer lower than it. For example, 4 factorial is 4 * 3 * 2 * 1, or 24. The output would then be The factorial of 4 is 24. This is the code given: public class Factorials { public static void main (String args[]) { // Write your code here } }arrow_forwardAll coding is done in Java. I am using IntelliJ Idea if it helps. 12. Bar Chart Write a program that asks the user to enter today's sales for five stores. The program should display a bar chart comparing each store's sales. Create each bar in the bar chart by displaying a row of asterisks. Each asterisk should represent $100 of sales. Example: Enter today's sales for store 1: 1000 [Enter] Enter today's sales for store 2: 1200 [Enter] Sales Bar Chart Store 1: ********** Store 2: ************arrow_forward
- In java A Carpet Company has asked you to write an application that calculates the price of carpeting for rectangular rooms in a building. To calculate the price, you multiply the area of the floor (width * length) by the price per square foot of carpet. For example, the area of floor that is 12 feet long and 10 feet wide is 120 square feet. To cover that floor with carpet that costs 300 per square foot would cost (12 * 10 * 300 = 36000.) First, you should create a class named RoomDimension that has two attributes: one for the length of the room and one for the width. Provide getters/setters, parameterized constructor and a toString method. The RoomDimension class should also have a member function that returns the area of the room. Once you have written the class, use in a test application that asks the user to enter the number of rooms in building create array of that size, then ask user to enter dimensions for each room, also ask user for price per square foot of the desired…arrow_forward5. You are playing a game that has two dice - one die has 6 sides numbered 1 through 6 and the second die has 8 sides numbered 1 through 8. A turn involves rolling both die together. Write Java code to play 1,000 turns and keep track of the sum of the two dice in each roll I.e, (2 through 14). When all 1,000 turns have been completed, print a formatted table showing the value of the sum of the two dice (2 through 14) and the number of times that value occurred.arrow_forwardThis program uses Java. You will be making a general class that will be called “GeneralBusiness”. This class must have the following methods: selectSalesTax() – This method will read in a file “stateTaxInfo.txt” that has the name of a state and the tax percentage (decimal form) for that state and save them to the given arrays. It will then print a menu for the user to choose the state that the business is in and set the variables to hold the values. getCustomerName() – This method will prompt the user for the name of the person using the program calcSalesTax() – This method will be sent a subtotal and calculate the sales tax outputReceipt() – This method will output a generic receipt as follows: Subtotal $37.50 Sales Tax $2.44 Total $39.94 outputMenu() - This method will receive the number of items and output a generic menu as follows: Item 1 Item 2 Item 3 Item 4 must have the following variables: stateNames - array saleTax – array saleTaxAmount theStateName subtotal total firstName…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
CPP Function Parameters | Returning Values from Functions | C++ Video Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=WqukJuBnLQU;License: Standard YouTube License, CC-BY