EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 6, Problem 1PE

a.

Explanation of Solution

Program:

File name: “CountByFives.java

//Define a class named CountByFives

public class CountByFives

{

    //Define main method

    public static void main(String[] args)

    {

        //For loop that counts by five from 5 through 500

        for(int i = 5 ; i <= 500 ; i+=5)

        {

            //Print the result

            System...

b.

Explanation of Solution

Program:

File name: “CountByAnything.java

//Import necessary header files

import java.util.Scanner ;

//Define a class CountByAnything

public class CountByAnything

{

    //Define main method

    public static void main(String[] args)

    {

        //Create scanner class

        Scanner sc = new Scanner(System.in);

        //Prompt the user to enter an integer

        System.out.print("Enter an integer:");

        //Get the integer from the user

        int n = sc.nextInt();

        //Declare a variable and initialize the value

        int count = 0 ;

/*For loop that counts by the entered number from 5 through 500*/

>&#...

Blurred answer
Students have asked these similar questions
Write an application named, Lab14.java. This application will do the following: 1. Display an introductory message 2. Choose a random word from the file, wordlist.txt, and display it 3. Disguise the selected word, and display it 4. Ask the user whether to continue, i.e., whether to repeat steps 2, 3, and 4, or quit the application Once the user chooses to stop the application: 5. Display the total number of vowels hidden 6. Display the total number of consonants hidden 7. Display termination message The user will be asked whether to continue playing and will indicate that another game is to be played by answering ‘y’ or ‘Y’ in response to the question, “Want to play again?” asked by the program after displaying each chosen word and its disguised version. If the user’s response is any character other than ‘y’ or ‘Y’, the totals are displayed and then the application termination message is displayed. See examples below. About randomly choosing a word from the file, wordlist.txt, found on…
Write an application that allows a user to enter the names and birthdays of up to 10 friends. Continue to prompt the user for names and birthdates until the user enters the sentinel value “ZZZ” for a name or has entered 10 names, whichever comes first. When the user is finished entering names, produce a count of how many names were entered, and then display the names. In a loop, continuously ask the user to type one of the names and display the corresponding birthdate or an error message if the name has not been previously entered. The loop continues until the user enters “ZZZ” for a name. Save the file as BirthdayReminder.java.
Write an application that allows a user to enter the names and birthdates of up to 10 friends. Continue to prompt the user for names and birthdates until the user enters the sentinel value ZZZ for a name or has entered 10 names, whichever comes first. When the user is finished entering names, produce a count of how many names were entered, and then display the names. In a loop, continuously ask the user to type one of the names and display the corresponding birthdate or "Sorry, no entry for name" if the name has not been previously entered. The loop continues until the user enters ZZZ for a name. An example of the program is shown below: Enter a name Lan Enter birthdate with slashes between the month, day, and year 12/25/1983 Enter a name or ZZZ to quit Marylouise Enter birthdate with slashes between the month, day, and year 2/20/1992 Enter a name or ZZZ to quit Arminda Enter birthdate with slashes between the month, day, and year 8/30/1992 Enter a name or ZZZ to quit Gudrun Enter…
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
C - File I/O; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=cEfuwpbGi1k;License: Standard YouTube License, CC-BY
file handling functions in c | fprintf, fscanf, fread, fwrite |; Author: Education 4u;https://www.youtube.com/watch?v=aqeXS1bJihA;License: Standard Youtube License