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


ADVERTISEMENT

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

Display Lowest And Then Next Lowest Number From Array

Jan 5, 2015

I am not getting the result I am looking for, but I'm sure I'm on the right track. I have an array, names + times of marathon runners, and should end up with a program that displays the slowest runner, and the next-slowest runner.

Currently, I get this:
The lowest time is 273.
The lowest time is 243.

Changing names.length to times.length changes nothing.
for (i = 1;... ) changes nothing.

The displayed number should currently only be 243. Why is it displaying 273 first, and at all?

The code:

class Marathon {
public static void main (String[] arguments) {
String[] names = {"Elena", "Thomas", "Hamilton", "Suzie", "Phil", "Matt", "Alex", "Emma", "John", "James", "Jane", "Emily", "Daniel", "Neda", "Aaron", "Kate"};
  int[] times = {341, 273, 278, 329, 445, 402, 388, 275, 243, 334, 412, 393, 299, 343, 317, 265};
  int min = times [0];
  for (int i = 0; i < times.length; i++) {
if (times[i] < min){
min = times[i];
System.out.println("The lowest time is " + min +".");
}

View Replies View Related

Java Program - Find Next Highest Or Lowest Prime Number

May 2, 2014

Java program takes positive int from user and determine if prime. Next the program finds next highest or next lowest prime number.

import java.io.*;
import java.util.*;
public class pa2take2 {
public static void main (String[]args){
int menus; //menu selection

[Code] ......

View Replies View Related

Unable To Pull Data From Another Class Into GUI Already Extending JFrame

Apr 26, 2014

I've been trying to pull data from another class file "Calculations.java" and have it be displayed in a TextField in "DataAnalyzerGUI.java". Here is how the hierarchy is broken down for my assignment:

DataAnalyzerGUI.java extends JFrame
ReadFiles.java extends DataAnalyzerGUI.java
Calculations.java extends ReadFiles.java

Everything displays and functions correctly in a command prompt if I use a line like this:

System.out.println ("Lowest opening " + dateArray[lowestOpenIndex] + ": " + dataArray[lowestOpenIndex][2]);

But trying to get it to display in a GUI has been quite troubling.

I know the code is supposed to look something like this:

dataOutput.setText(DESIRED CODE HERE);

But I am unable to find anything of value to work out.

I have attached my complete project....

Attached File(s)

Assignment 4.pdf (247.05K)
Assignment 4.zip (235.81K)

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

Unable To Find Prime Palindrome Numbers Less That A Number By Program

Oct 10, 2014

I want to find the prime palindrome numbers less that a given number by my program. Here is my code, I am trying to find the method to solve the errors when I compile it. It said variable a might not have been initialized in line 41,62,86.

import java.util.Scanner;
public class Lab5{
public static void main (String[] args){
System.out.println("Please input a number");
Scanner Input=new Scanner(System.in);
int num = Input.nextInt();

[Code]...

View Replies View Related

Unable To Print Out Results Of Program That Calculate Number Of Seats

Nov 11, 2014

I'm trying to print out the results of a program that calculates the number of seats the parties will get in an election.I have to print the partial results and the national results.

I can print te number of seats per party in each constituency, but how can i sum all seats per party in each constituency and print the national results?I'm working with vectors, which I know it might not be the best option, but everything is working, except the fact that I can't loop throuhg the vector and retrieve the total sum per party.Like, adding the seats for labour party in Constituency A and B and C, etc, and print the sum. And do the same for conservative party.Is it possible, or doIhave to create a method in Parties class to solve the problem?

This is what I have now.

for (Parties p : h.geral) {
show += String.format("Constituency - %5s - %5s - %d%n",
p.getConstituency(), p.getParty(), p.getNum_seats());
}

View Replies View Related

Program To Pull Prime Numbers Between Two Entered Values

Oct 18, 2014

Program to pull prime numbers between two entered values,

import java.util.Scanner;
public class question6 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter lower int:");

[Code] ....

View Replies View Related

Find The Lowest Number?

Apr 12, 2014

I have to find the average, highest, and lowest numbers in an array. I already have the average and highest, and I thought I could find the lowest number the same way I found the highest, but it's not working. It just keeps coming out to 0. I've tried out different ways, but I want to see if there are better ways than doing MAX_VALUE for the lowest, then looping it through.

import java.util.Scanner; 
public class Test_Scores {
public static void main(String[] args) {
//array,scanner,values

[Code].....

View Replies View Related

Write A JAVA Program That Will Input 10 Scores And Output Highest And Lowest Score

Jan 9, 2015

1.Write a JAVA program that will input 10 scores and output the Highest and Lowest score.

2.Write a JAVA program that will input the base and power and display the result: Example: Base is 4 Power is 2 the answer is 16 (Note: Math.pow( ) method is not allowed)

3.Write a JAVA program that will input an integer number, and then will output the sum of all inputted numbers. The program will stop in accepting inputs if the user entered 0.

View Replies View Related

Unable To Increase Tvalue Of Number By One After Each New Runner Added

May 6, 2014

I have been playing around all day trying to get this to increase the value of number by one after each new runner is added. How to get the value of number to increase after each record is added?

public class Runner
{
/* static variables */
/* instance variables */
private int number; // runner's number
private String name; // runner's name
private String ageGroup; // standard, junior or senior
private int time; // runner's marathon time in minutes

[Code]...

View Replies View Related

Push And Pull In Eclipse

Dec 9, 2014

I'm quite new in android programming and I've meet some problem in push and pull method. I have created 2 activity in my app 1 of them call Push_activity and Pull activity(Code are shown below). The String that I keyed in PushActivity have to "transfer" to the PullActivity when the button is pressed:

PullActivity

but1 = (Button)findViewById(R.id.buttonll);
tx = (TextView)findViewById(R.id.editText1);
tx.setText(getIntent().getStringExtra("extra"));
but1.setonclickListener(new onclickListener(){

[Code] ....

The app works fine when it started. When I press the button in PushActivity, it crashed and the error came from my textview in PullActivity.

View Replies View Related

AverageDriver Won't Pull Data Correctly

Dec 12, 2014

I'm unable to get the output for "AverageDriver" to print correctly(5 scores in descending order and average). The output displays the scores the same way they are entered and the average is always zero. The output for the Average program works fine and with the correct output.

import java.util.Scanner;
//This class keeps 5 scores entered by the user
public class Average
{
private int[] data;
private double mean;
public Average()

[Code] ....

View Replies View Related

Unable To Make Gradebook That Uses Random Number Generator To Give Score

Nov 7, 2014

I`m trying to make a gradebook that uses random number generator to give the score, I also need to implement student numbers and sort everything with a total at the bottom. But I cant figure out how the bubblesorting works. This is my code so far:

package karakterbok;
import static java.lang.Math;
import java.util.Random;
public class Karakterbok {
public static void main(String[] args) {
Random karakterer = new Random();
Random studid = new Random ();

[Code]...

how to sort this using bubblesort?

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

Parse JSON Object To Pull Author?

Apr 15, 2015

I'm trying to pull the authors from this Json object but I'm having issues trying to pull the author only, I'm only able to get a huge string which is a valid JSON object i tested it in [URL]

private class RunSearch extends AsyncTask<String, Void, String> {
private Exception e;
protected String doInBackground(String ...query){

[Code].....

View Replies View Related

Number Guessing Program - Computer Guesses A Number That User Is Thinking Of Within Certain Range

Mar 28, 2015

I have a beginning Java Program I have been working on that creates a number guessing program where the computer guesses a number that the user is thinking of within a certain range. I so far have the program below, but need getting rid of a few kinks/ adding features.

-First, I need to set it up so that the user will be prompted and give a range. It should run and produce something like this:

Welcome to this first-ever mind-guessing program!

Please pick a range (higher than 1 and no larger than 50): 32

You will choose a number between 1 and 32... and I will try to guess it.

With each of my guess, you will tell me whether I am too high (h or H), too low (l or L), match (m or M), or you want to quit (q or Q). My objective is to find the number using as few guesses as possible.

-Second, the game is supposed to give up and restart after failing the five, guesses, but for some reason, after it fails the fifth time, it prompts a fifth guess once again instead, then restarts after- I need to prevent this, so that it should look something like this:

My fourth guess is 17: h
My guess is too high?

My fifth guess is 16: h
*** I am unlucky this round. I give up.

Let's play!

My first guess is 10:
etc..

import java.util.*;
import java.lang.Math;
public class numguessprac1 {
// Declaring variables
public static String input;
public static int quit;
public static int guess;
public static int wins;

[Code] ....

View Replies View Related

Program That Takes A User Inputted Number And Converts It To A Binary Number

May 5, 2014

trying to write a program that takes a user inputted number and converts it to a binary number.

Here's what I have:

package com.java2novice.algos;
import java.util.Scanner;
public class Converter {
static Scanner console = new Scanner(System.in);
public void printBinaryFormat(int number){
int binary = console.nextInt();

[Code]...

Bugs on:

Line 13
Line 17
Line 23

View Replies View Related

Program Is To Accept Number And Display New Number After Removing All Zeros

Dec 29, 2014

ex
Sample input:2340980
Sample Output:23498

this is the program i have tried but is dosent work

import java.util.*;
class zero
{
public static void main(String args[])
{

[Code]....

View Replies View Related

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 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

Unable To Set Text To A Label Multiple Times In Same Program

Aug 5, 2014

I am developing a java swing application. In which i want to set a different text to a label in same program ( in single JFrame). I dont want to use another JFrame instead i want to use setText method of java and set different text to a label at different intervals of time according to my need.

I am using java 1.7 sdk and pupy linux as OS. Below i am giving source code.

What i am doing is in constructor of class i am setting an image to JFrame and setting text "Welcom...". And when user clicks on this JFrame a method is called which will clear the text "Welcome.." and sets new text to another label "Enter...." and from there another method is called and it clears label "Enter..." and sets a text "Plzz wait..". and yet there are more methods, i havnt provided here.

But what is happening is it shows welcome text and then directly Plzz wait..

Its not showing text Enter... because control is finished after last method gets executed.

My concern is i want to show all the setText (my messages) in a sequence. Without using another JFrame. There is no any user input other than user will click on first welcome page.

public class BackgroundFrame extends javax.swing.JFrame {

JLabel setTitle1;
JLabel setTitle2;
JLabel setTitle3;
JLabel setTitle4;

[Code] ....

View Replies View Related

Unable To Create A Connection In JSP Program To MSSQL Database

Oct 7, 2014

i have a problem in connecting my jsp program in MSsql 2005 i want to create a connection in my jsp program to MSsql database but theres an error of my work here is my code

Code:

PHP Code:

<%@ page import="java.util.*" %>
<%@ page import="javax.sql.*;" %>
<%@ page import="java.sql.*;" %>
<%@ page import="java.util.Enumeration;" %>
<html>
<head><title>Sample MS connection</title></head>

[Code]...

View Replies View Related

Unable To Create A Program For Class Using Two Dimensional Arrays

Dec 6, 2014

I am trying to create a program for class the uses two dimensional arrays. I am stuck on the second step that states Use two parallel arrays. One is a two-dimensional array -- a row of this array will hold six values in this order: [0] number of hours worked, [1] hourly pay rate, [2] gross pay, [3] net pay, [4] federal withholding, and [5] state withholding.

This is what I have so far:

Java Code:

double [][] data = new double [30][6];
String [] names = new String [30];
String str = null;
String detail = null;
int n = input(data, names, inputFile); mh_sh_highlight_all('java');
(there's more but i don't believe it pertains to this question)

My question is how would I create this array. Or, is that right above? I've searched online and in my book and I just don't understand.

View Replies View Related

Create Little Program Which Enter Number / Program Says Triangle Exist Or Not

Mar 16, 2014

i want create little program which enter the number, ant program says triangle exist or not. So code :

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

[code]...

So when i put first num like 1, next num like 2 and next num like 100 , program says Triangle exist.

View Replies View Related







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