Array With Occurrences - Gather Sales Amount For The Week

May 3, 2014

Here is what I'm trying to do using arrays.

gather sales amount for the week
display the total of sales
display the average of sale
display the highest sale amount
display the lowest sale amount

using occurrences determine how many times the amount occurred for the week

make a sales main
make a sales data

This is what i have so far but I'm confused on how to start the occurrence and where it would be placed in order to get the information from the array

public class SalesData {
private double[] sales; // The sales data
/**
The constructor copies the elements in an array to the sales array.
@param s The array to copy.
*/
public SalesData(double[] s) {

[Code] .....

View Replies


ADVERTISEMENT

Enter In Sales Amount And Then Get It To Display Asterisk Per 100 In Sales

Apr 3, 2014

{
public static void main (String []args)
{
Scanner numberin = new Scanner (System.in);
double store [];

[Code]....

How would I get my program to display a * for every 100 dollars in sales that the user enters in so: for example the user enters in store 1: $ 400 in sales for the store I want it to display store 1:****

The first part of my code allows the user to enter in whatever values the stores have in sales. The Second half of the code starts at line 19 is my best guess on what I need to do I just am not sure how to get it to display what I need it to.

View Replies View Related

Eclipse Java Programming Sales Commissions Array Sales In Ranges

Oct 9, 2014

i have to ask user gross sales until -1 sentinial and to get the commission to put in groups its 9% times the sales add $200
the groups are formatted
a) $200-299
/> $300-399
....
i) $1000 and over

import java.util.Scanner;
public class Commissions {
/**
* @param args

[Code]....

View Replies View Related

GregorianCalendar - Setting The First Day Of Week To Sunday Changes Week Number

Mar 23, 2015

Why does setting the first day of week to Sunday changes week number? This piece of code
 
public static void main(String[] args) throws Exception {
System.out.println(System.getProperty("java.runtime.name") + " " +
System.getProperty("java.runtime.version"));

[Code].....

View Replies View Related

Read File Of Sales Records And Produce Sales Report

Jun 29, 2014

Design a program that will read a file of sales records and produce a sales report. Each record in the file contains a customer's ID, name, a sales amount, and a validated GST code. The GST code is to be applied to the sales amount to determine the sales tax due for that sale, as shown below.

GST CodeGST Rate
0
1
20%
5%
10%

The report is to print a heading "SALES REPORT", and detail lines listing the customer's ID, name, sales amount, sales tax, and total amount due including sales tax.

Is assignment
sofar:pseudo code
SalesReport
Read customer file
Get TaxCode
Get GSTAmount SalesTax
Calculate SalesTax

[Code] ....

View Replies View Related

Count Number Of Occurrences Of A String In Array List?

Apr 6, 2015

I am trying to count the number of occurrences of a string in an array list. I used the following code:

int count = Collections.frequency(strings, search);

strings is the name of the array list and search is the string that I am trying to count the number of occurrences of. My program compiles correctly, but when I enter the string to search for, I get the following error: "Exception in thread "main" java.lang.NullPointerException at java.util.Collections.frquency(Collections.java:37 18)

Why am I getting this error message and how do I fix it?

View Replies View Related

Find And Remove All Occurrences Of Given Integer And Return Amended Array

Jan 12, 2014

Question - Given an specific integer and an array of integers, find and remove all occurrences of the given integer and return an amended array. I solved it. Here is my solution -

public static void main(String[] args) {
int[] nums = {1, 2, 3, 4, 4, 4, 5, 6, 7, 8, 8, 8, 8, 7, 7, 9};
int input = 8;
int newLen = nums.length;
for(int i=0; i<newLen; i++){
if(nums[i] == input){

[Code] ....

View Replies View Related

Efficient Way To Gather Data From Site Page

Oct 22, 2014

I'm looking for a way to gather data from a site page. all data is shown in the same page... I am trying to get the content and parse it is a bit crazy as data seems to be not organized. Itried to get it as a document but still looks crazy.

As all data is shown very clearly in the page (I would like every row to be an object) I'm sure there is some way to collect this data easily. (the data is from this page: [URL] ....)

I'll attach a snapshot and the content I got from the website.

in-play.jpgall_in-play_page.txtin-play.jpgall_in-play_page.txt

View Replies View Related

Get Character Count And Amount Of Vowels In String Array?

Jan 29, 2015

I have to write some code to take names from the user and then order them in alphabetical order and then print them out which i have managed to do. However, i can't get it to count the characters in the names that the user enters or count the amount of vowels in the names.

This is the code ive written:

import javax.swing.JOptionPane;
import java.util.Arrays;
String[] names = new String[9];
int i;
names[0] = JOptionPane.showInputDialog("Please enter a name");
names[1] = JOptionPane.showInputDialog("Please enter a name");

[code]....

View Replies View Related

User Should Be Able To Enter Amount Of Digits Array Should Be Shifted Left

Nov 6, 2014

This is the other code problem I have. The user should be able to enter the amount of digits the array should be shifted left. For example, if the user entered 3 and the array was 1 2 3 4 then it should return 4 1 2 3. here is my code.

public char[] replaced(char[] array, char oldChar, char newChar) {
char myFun[] = new char[array.length];
for (int i = 0; array.length > i; i++) {
myFun[i] = array[i];

[code]....

View Replies View Related

Check If Lotto Number Has Been Or Not In Last Week

Nov 25, 2014

I need to check numbers from 1-39 and see if the number has been or has not been a winning number in the last week lottery. How to do that?

This is code for random number, 7 numbers

import java.util.ArrayList;
import java.util.Random;
public class Loto {
public static void main(String[] arg) {
ArrayList<Integer> al = new ArrayList<Integer>();
for(int i = 1; i <= 39; i++)

[Code] ....

View Replies View Related

How To Calculate Difference Between Two Entered Days Of Week

Mar 19, 2014

I need to create a simple Java program that calculates the difference between two entered days of the week with the following requirements:

-Ask the user to enter in a day of the week by name (e.g. Monday)
- Ask the user to enter in another day of the week by name (e.g. Friday)
- Create a static method other than main that takes in two Strings as input, and returns an integer value equal to the difference between the two days
- Use an array with the days of the week in it to find each entered in day of the week, and use their indices to calculate the difference
- Output the difference for the user to see

View Replies View Related

Unable To Pull Out Lowest Week Number In Program

Apr 29, 2014

This program reads off of a text file that I have attached to my post. It is supposed to:

display the total sales for each week
the average daily sales for each week
the total sales for all of the weeks
the average weekly sales
the week number that had the highest amount of sales
the week number that had the lowest amount of sales

I can get everything but the very last one. In my code you will see that I tried to use a really large number so it would pull out the lowest amount, but it still didn't work: low = 100000000;

 SalesData.txt (173bytes)
Number of downloads: 29
import javax.swing.JOptionPane;
import java.io.*;
import java.text.DecimalFormat;
import java.util.Scanner;

[code]....

View Replies View Related

App That Calculates And Displays Total Basic Pay Week - Overtime Pay

Oct 16, 2014

Having just started college, Bob has been busy looking for a part-time job to fund his new college social life and after only two weeks of looking he has managed to get two job offers! Each job comes with different hours, basic rates of pay and over-time rates so he needs to work out which would get him the most money.

Develop an application that would allow Bob to enter his basic pay rate, his number of regular hours work per week and his number of overtime hours per week. The application should then calculate and display Bobs total basic pay for the week, his overtime pay for the week and his total pay including overtime.

Your application should use instantiable classes to separate the calculations from the user input and output.

Save the instantiable class as Pay.java

Note: The overtime rate is 1.5 times the basic rate of pay

This is my instantiable class code which compiles correctly

public class Pay{
//Declare Data members/Variables
private double pay;
private double hours;
private double overtime;
private double totalBasicPay;

[Code] .....

My errors in the second bit of code that i have never seen before

"C:UsersAndreDownloadsPayApp.java:25: error: no suitable method found for println(<null>,String)
System.out.println(null,"Please enter Basic Pay");
^
method PrintStream.println() is not applicable
(actual and formal argument lists differ in length)

[Code] .....

View Replies View Related

Returning All Occurrences Of C In String

May 13, 2014

Write a method that accepts an array of Strings and a character c. The method must return the count of all cs in the strings of the array.

Here's what I have written:

[
public int countC(String[] strings, char c) {
int count = 0;
for(int i = 0; i < strings.length; i++) {
for(int j = 0; j < strings[i].length(); j++) {
if(strings[i].charAt(j) == c) {
count++;
}
}
}
return count;
}]

Does this look correct?

View Replies View Related

Repetition - Print Number Of Occurrences

Apr 11, 2015

find whether it is a repetition free number or not. If it is, print the same number(x), else if it has repetitions then print the number of occurrences of the first repetitive digit you encounter.

View Replies View Related

Number Of Occurrences Of Specified Character In A String

Oct 16, 2014

the number of occurrences of a specified character in a string...i tried to do the program occurrences in a given string and i tried the code as below.

code:

import java.util.*;
public class Occurrence
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);

[code]....

View Replies View Related

Removes All Occurrences Of Specified String From Text File?

Apr 30, 2014

Write a program that removes all the occurrences of a specified string from a text file. For example, invoking java Exercise14_11 John filename removes the string John from the specified file. Your program should get the arguments from the command line.

I have a problem.

Text document is Match.txt
Match.txt contains a string: "Open the door John"

I tried to create a new file named doc.txt where to put the text from the Match.txt without John word

//to read from document
Scanner output = new Scanner("Match.text");
//to write to document
PrintWriter write = new PrintWriter("doc.txt");
//copy from original document
String copy = "";
while(output.hasNextLine())

[code]...

Error :NoSuchElementException

View Replies View Related

Word Puzzle Game - Add Extra No Occurrences

Oct 20, 2014

I have a simple Word Program here called PuzzleGame.java. It works perfectly but I wanted to add some bells and whistles to it. So I want to be able that if the user selects the same letter more than once a message comes up letting the user know that "That letter has already been selected, try another letter."

I am certain that if would go in the 'else' of the 'if( )' that I am providing.

import java.util.Scanner;
public class PuzzleGame {
public static void main(String[] args){
String secretPhrase = "BIG JAVA";
String guesses = " ";

[Code] .....

I am thinking maybe after the else in this if statement.

if(guesses.indexOf(secretLetter)== -1) {
System.out.print("-");
notDone = true;
} else {
//something here. I am not sure how to go about it.
System.out.print(secretLetter);
}

View Replies View Related

See Occurrences Of A Character In A String Stored In Text File

Apr 26, 2014

I have this program to see the occurrences of a character in a string stored in a text file. My text file has the following contents (as shown below):

P-P-N-N-L-V
N-R-U-S-R-Q
K-Q-E-L-E-A
A-J-B-G-E-F
F-E-L-Q-R-R
U-F-J-V-I-M
P-I-Q-K-B-K
U-N-L-F-O-B
M-A-N-M-H-O
P-Q-J-D-N-I
G-U-O-D-F-I
Q-M-M-B-C-Q
N-B-I-L-E-J
S-A-T-Q-H-U
C-L-G-U-J-M
R-P-V-M-A-A
C-R-A-V-L-B
M-U-Q-K-M-Q
E-I-C-H-V-J
J-N-N-K-R-P

As you notice, each character is seperated by a hyphen (serving as its delimiter). I want to only go through 10 lines in the text, instead of all 20 of them. So, I wrote the program in such a way that I intend to reach into the indices of each character in the text file. Since there are six characters in each line so that means there are 6 indices - and there are 10 lines I only want to go through. So, 6 indices times 10 lines equals 60 indices. Hence, there are only 60 indices I need to go through. In that manner, it's like I have gone through only 10 lines through that way.

It compiled perfectly fine but upon running it, I ran through an error in the black DOS screen that says

"java.lang.ArrayIndexOutofBoundsException: 6 ".

How do I work around that?

The code I wrote is shown below...

import java.io.*;
import java.util.*;
public class hotandcoldclusterdeterminer_test {
public static void main (String args [])throws IOException {

[Code]....

View Replies View Related

Sales Tax Increase At 6% Not Working

Feb 8, 2015

import java.util.Scanner;
public class SalesTax {
public static void main(String [] args) {
Scanner input = new Scanner(System.in);
 
double total = 0;
double currentTax = 0;

[Code] .....

View Replies View Related

Software Sales Program

Nov 7, 2014

my project is to design a class that stores the number of units sold and has a method that returns the total cost of the purchase..the given info is unit are $99. discounts are 20% for 10-19 units; 30% for 20-49 units; 40% for 50-99 units; and 50% for 100 or more units purchased... When i run the code and put in the units sold it returns: 0 units sold, $0.00 cost, 0% discount. How do I get the output to actually do the equation and give proper information. We were given a demo file from the instructor and had to create a class that works with it first set of code is the demo file:

package chapter4;
import java.text.DecimalFormat;
import java.util.Scanner;
/**
* SoftwareSalesDemo Program
*/
public class SoftwareSalesDemo {
public static void main(String[] args) {
int units; // To hold units sold

[code]....

View Replies View Related

Program To See Occurrences Of A Character In String Stored In Text File

Apr 26, 2014

I have this program to see the occurrences of a character in a string stored in a text file. My text file has the following contents (as shown below):

Quote
P-P-N-N-L-V
N-R-U-S-R-Q
K-Q-E-L-E-A
A-J-B-G-E-F
F-E-L-Q-R-R
U-F-J-V-I-M
P-I-Q-K-B-K
U-N-L-F-O-B
M-A-N-M-H-O
P-Q-J-D-N-I
G-U-O-D-F-I
Q-M-M-B-C-Q
N-B-I-L-E-J
S-A-T-Q-H-U
C-L-G-U-J-M
R-P-V-M-A-A
C-R-A-V-L-B
M-U-Q-K-M-Q
E-I-C-H-V-J
J-N-N-K-R-P

View Replies View Related

Sales Opportunity - Summing Up Variables?

Aug 7, 2014

I have this small program that creates a sales opportunity and its related products, and then prints out the opportunity name, total quantity and total price

class Opportunity{
String name;
int Amount;
String Stage;
int Product_quantity;

[Code] .....

The code works as expected, and is successfully prints :

Opportunity Name: Sales
Opportunity Amount: 110
Opportunity Product Quantity: 3

That said, I feel the way the OpportunityCreator class sums up the quantities and prices (see the comments on the code) is very inefficient, and would only work if there were 3 or less products. How can I design this so that it sums the quantities and prices of all the Product objects that I create, regardless of how many of them are? I understand probably I'd need to redesign the whole thing but I'd like to get at least an idea of how this can be achieved.

Originally I was thinking of creating an ArrayList and adding all the prices/quantities there but wasn't sure how to do. I also thought of using a loop to loop through the different object references and sum the quantity/price but was also unsure on how to do so?

View Replies View Related

Average Daily Sales For Store

Feb 12, 2015

I am working on trying to show the average daily sales for the store. I cannot quite figure out why my calculation is not working. Everything works except my average sales is always $0.00... lines 185-189 is where my calculation is located.

Java Code:

import java.util.*;
import java.text.*;
import javax.swing.JOptionPane;
/*******************************************************************************
* Create a fancy class for a cash register.
*******************************************************************************/
public class fancyRegister{
/** current amount due */
private double currentAmount;

[Code] ....

View Replies View Related

JGrasp - Writing A Program For Ticket Sales

Sep 13, 2014

The manager of a football stadium wants you to write a program that calculates the total ticket sales after each game. There are four types of tickets: box, sideline, premium, and general admission. After each game, the data is stored in a file in the following format:

ticketPrice numberOfTicketsSold

Sample data might look like:

250 5750

100 28000

50 35750

25 18750

The first line indicates that the box ticket price is $250 and that 5750 tickets were sold at that price.

Your program should input in this data (using Scanner or an input dialog box), then output that data to a message dialog box along with total ticket sales information. Output the total number of tickets sold and the total sale amount. Make your output user-friendly and "pretty". Format your output with two decimal places. Use JOptionPane and the formatting techniques learned in chapter 3 for your output. Example output might be:

5750 Box Tickets sold at $250.00
28000 Sideline Tickets sold at $100.00
35750 Premium Tickets sold at $50.00
18750 General Admission tickets sold at $25.00

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved