Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9089153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:04:48+00:00 2026-06-16T22:04:48+00:00

This is an assignment in my Java course where we have to use methods

  • 0

This is an assignment in my Java course where we have to use methods to solve problems. I have most of this one done but I’m having trouble.

Assignment:

Graphs help to display data. Create a table similar to the one shown below. The numbers generated are to be created as random numbers between $10,000 and $40,000. The numbers and graph indicate the sales from a wholesaler during the month of October. Note that they are not open seven days a week. (Sunday is the day they are closed, and Sundays fall on October 1, 8, 15, 22, and 29 during the year in question. The graph is generated in that each star represents $1,000 in sales.

Your graph will not look exactly like this since random numbers will be generated differently in each program. Print the dates in columns as shown (right-justified). Also, Mondays always have sales over $30,000 and Tuesdays always have sales over $20,000. Saturdays always have sales less than $15,000.

Sample output:

Day Daily   Sales Graph
2   37081   *************************************
3   28355   ****************************
4   39158   ***************************************
5   24904   ************************
6   28879   ****************************
7   13348   *************

9   38791   **************************************
10  32564   ********************************
11  23867   ***********************
12  18154   ******************
13  25830   ***********************
14  14092   **************

16  36861   ************************************
17  26207   ************************
18  10921   **********
19  16573   ****************
20  33423   *********************************
21  12766   ************

23  33770   *********************************
24  28823   **************************
25  38883   **************************************
26  20959   ******************
27  16262   ****************
28  13269   *************

30  33557   *********************************
31  22579   **********************

I have most of it here:

import java.util.*;
public class Prog310t
{
    public static Integer randomNumbers (int minNumber, int maxNumber)
    {
        Random gen = new Random();
        return (gen.nextInt(maxNumber - minNumber + 1) + minNumber);
    }

    public static String starLine (int numberOfAsterisks)
    {
        String stars = "";
        for (int i = 0; i < numberOfAsterisks; i++)
            stars = stars + "*";
        return stars;
    }

    public static void main (String args [])
    {
        int randomNumber;
        System.out.println("Day\tDaily\tSales Graph");
        for (int x = 2; x <= 31; x++)
        {
            if (x == 8 || x == 15 || x == 22 || x == 29)
            {
                System.out.println();
            }
            if (x == 2 || x == 9 || x == 16 || x == 23 || x == 30)
            {
                randomNumber = randomNumbers(30000, 40000);
                System.out.println(x + "\t" + randomNumber + "\t" + starLine(randomNumber / 1000));
            }
            if (x == 3 || x == 10 || x == 17 || x == 24 || x == 31)
            {
                randomNumber = randomNumbers(20000, 40000);
                System.out.println(x + "\t" + randomNumber + "\t" + starLine(randomNumber / 1000));
            }
            if (x == 7 || x == 14 || x == 21 || x == 28)
            {
                randomNumber = randomNumbers(10000, 15000);
                System.out.println(x + "\t" + randomNumber + "\t" + starLine(randomNumber / 1000));
            }
        }
    }
}

How would I go about making it output the other days? It only outputs the Sundays (blanks), Mondays, Tuesdays, and Saturdays. How do I make it output the other days without having to put every single day number?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T22:04:49+00:00Added an answer on June 16, 2026 at 10:04 pm

    Use a for loop for the days, that only allows 31 days, nested within a for loop for weeks. Check the specialty days and generate the random number based upon the day.

    import java.util.*;
    public class Prog310t
    {
        public static Integer randomNumbers (int minNumber, int maxNumber)
        {
            Random gen = new Random();
            return (gen.nextInt(maxNumber - minNumber + 1) + minNumber);
        }
    
        public static String starLine (int numberOfAsterisks)
        {
            String stars = "";
            for (int i = 0; i < numberOfAsterisks; i++)
                stars = stars + "*";
            return stars;
        }
    
        public static void main (String args [])
        {
            int days = 1;
            for(int week = 0; week < 5; week++){
                for(int day = 1; day < 8 && days < 32; day++){
                    int randomNumber = 0;
                        if(day==1){
                            randomNumber = 0;
                        }else if(day == 2){
                            randomNumber = randomNumbers(30000, 40000);
                        }else if(day==3){
                            randomNumber = randomNumbers(20000, 40000);
                        }else if(day==7){
                            randomNumber = randomNumbers(10000, 15000);
                        }else{
                            randomNumber = randomNumbers(10000, 40000);
                        }
                    System.out.println(days + "\t" + randomNumber + "\t" + starLine(randomNumber / 1000));
                    days++;
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My assignment in my Java course is to make 3 triangles. One left aligned,
I'm having trouble resolving a CCE. This assignment calls for the user to open
I'm doing another Java project for my class. In this assignment, we have to
I have this assignment that I've tried. But when I enter 1 it should
I am having trouble with this assignment because my of my actionlisteners. Right now
so we're doing this assignment at Uni and i have a serious craving to
OK, I have this assignment and I have to prompt the user for data
Hey there I have just started Java for a course I will be taking
I am working on an Java assignment for a software design course in my
First off this is for homework or... project. I'm having trouble understanding the idea

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.