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
ADVERTISEMENT
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
Nov 29, 2014
We were given the assignment to program a lotto game. in our game we should do follow the following steps below, and we are supposed to use atleast tree methods. the first one to receive the array of integers and an integer and check if the int was not entered before. the user should not repeat the same number. the other method will draw all numbers of a game (quantity of numbers to draw is based on the number parameter) and returns them in an array. the last method will display the result of the game. It receives a list of all lines played and a list of all numbers draw.
these are the steps to follow:
1. Ask the user how many lines (games) the user would like to play. Each line is made of five numbers between 1 and 45 (inclusive).
2. Ask the user to enter five numbers between 1 and 45 (inclusive) for each line. The user must NOT be allowed to enter a number more than once for each line.
3. When all the numbers for all the lines are entered, the program should display all lines and asks the user to confirm the game. If the user does NOT confirm the game, the program should start all over again.
4. Draw (generate) five numbers between 1 and 45 (inclusive). The numbers should be unique within the draw.
5. Draw (generate) one number (the bonus number) between 1 and 45 (inclusive). The number should be unique within the draw.
6. Display all the lines played and the result of each line.
7. Ask the user if the person would like to play again, if so the program should start the process all over again.
View Replies
View Related
Sep 25, 2014
1. Write a Java program that randomly generates a five-digit lottery number and prompts the user to enter a five-digit number. Each digit in the number is in the range between 0~9. The program should determine which prize the user wins according to the following rule:
- The user wins the first prize if the user input matches all five digits in the lottery number in exact order.
-The user wins the second prize if the user input matches any four digits in the lottery number in exact positions.
-The user wins the third prize if the user input matches any three digits in the lottery number in its exact position.
-The user wins the fourth prize if the user input matches any two digits in the lottery number in its exact position.
- The user wins the fifth prize if the user input matches any one digit in the lottery number in its exact position.here is my code. I have tried replacing the && statements with || and it always returns either case 1 or case default.
import java.util.Scanner;
import java.util.Random;
class Hw5 {
static int getPrize(int g1, int g2, int g3, int g4, int g5,
int u1, int u2, int u3, int u4, int u5) {
[code]...
View Replies
View Related
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
Nov 18, 2014
I'm trying to come up with a method that would validate each turn a player makes. For a turn to be valid, it has to only contain numbers from 0 to 3(inclusive) and at least one digit must not be 0. Here is what I`ve come up with so far. For example, with "303" as the number and "101" as the turn, the turn would be valid and my method should return true, but it does not.
public static boolean turnIsValid (String number, String turn ){
boolean rep=false;
int pos1=0;
char min='0';
char max='3';
while(number.length()==turn.length()&&pos1<turn.length()){
[Code] ....
View Replies
View Related
Aug 8, 2014
Faster algorithm.... I want to know whether a number n1 is divided by n2 without remainder. I know I can simply write if (n1 % n2 == 0) ... But it's not fast enough.
Currently I use:
double div = (double) n1 / (double) n2;
If (div == (int) div){
...
}
This is faster than the mod operator. I just look forward to any micro optimizations or such.
View Replies
View Related
Jun 8, 2014
im trying to make a linear search method to check if a number 'n' is included in an array.
PHP Code:
package test;
public class Recursion {
public static void main(String[] args) {
}
static int linearSearch(int n, int[] array)
[code]....
Im getting the following error: this method must have a result type of type int ?? i already have a return type of type int...
View Replies
View Related
Apr 14, 2015
I have this program where I'm supposed to fill an array with 1000 indices with 1000 randomly generated numbers between 1 and 1000. The program is supposed to check if any of the numbers match an index that is the same value (so for example, the number 4 is in index 4). How to check for that condition, especially using a binary search (I'm also told to use a binary search).
Right now the variable index isn't initialized because I don't know what to initialize it to exactly. How do I check to see if any numbers match the value of the same index?
import java.util.*;
public class Identity {
public static void main(String[] args) {
int [] integers = new int [1000];
// Fill array with randomly generated numbers
int [] display = GenerateRandom(integers);
[Code] ....
View Replies
View Related
Apr 13, 2014
Write a program that prompts the user for an input number and checks to see if that input number is greater than zero. If the input number is greater than 0, the program does a multiplication of all the numbers up to the input number starting with the input number. For example if the user inputs the number 9, then the program displays the following sum:
9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1 = 362880
That's the question I'm getting and so far all I've got is
import java.util.Scanner;
public class Lab4Q3
{
public static void main (String[] args)
{
int keyboard;
[Code] .....
View Replies
View Related
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
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
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
Nov 25, 2014
I am having trouble figuring out how to check for win in tic tac toe, the way my teacher wants it is with various if statements but im not sure what to put in the parentheses. I think it would be something like
if(button==button.getIcon(x)) {
if(button2==button2.getIcon(x)) {
if(button3==button3.getIcon(x)) {
playerWon=true;
player2Won=false;
}
}
}
This is what i have so far
import java.awt.Container;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class TicTacToe extends JFrame implements ActionListener
[Code] .....
View Replies
View Related
Oct 19, 2014
This SHOULD be a simple program, the gist of it is Given an element E and the array A that represents a set X (user input), write a program that determines whetherE is an element of X.I have the array list all set up to take the user input and make zero the last element of the array. I want user to input numbers into array, then have fixed numbers for E and check to see if E is in the Array. I guess I'm not sure how to check the array and see if E is in the array? Here is what I have so far...
import java.util.ArrayList;
import java.util.Scanner;
import java.util.List;
import java.util.InputMismatchException;
public class Set {
public static void main(String[] args) {
List<Integer> userInputArray = new ArrayList<Integer>();
[code]...
View Replies
View Related
Jul 9, 2014
I am having an issue with my swing gui. I dynamically create tabs with information (textfields, checkboxes, combo boxes) and when I select the checkbox it disables or enables a textfield. Now when I select the checkbox it seems to resize everything, specifically my textfields from say 9 columns to probably one. I"m a little unsure why it is doing this but I have a feeling it may be an inheritence issue.
My code is below for my generation of the tabs and of the rest of the information on the gui. The gui is an inner rid layout with a top and bottom pane that are both gridbaglayouts and an outter pane as well. I am thinking I am missing something in the grid layout setup that is causing this.
private void initComponents() {
jTabbedPane1 = new javax.swing.JTabbedPane();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(new java.awt.GridLayout(1, 0));
pack();
[code]....
View Replies
View Related
Sep 30, 2014
1. In jsp 1 , i have 3 checkboxes(chkbox1,chkbox2,chkbox3) , if i select check boxes (chkbox1, chkbox2), and click on submit, corresponding two text fields (chkbox1,chkbox2) will have to appear in the next jsp i.e., jsp 2.
2. In jsp 1 , i have 3 checkboxes(chkbox1,chkbox2,chkbox3) , if i select check boxes (chkbox2, chkbox3), and click on submit, corresponding two text fields(chkbox2,chkbox3) will have to appear in the next jsp i.e., jsp 2.
Like this, which ever checkbox i select, corresponding text fields should appear in the subsequent jsp.
View Replies
View Related
Aug 25, 2014
I have to match pattern like 76XYYXXXX mean x can be 4or 5 and Y can be 6 or 7. All x and y should be same .i.e. 764664444
View Replies
View Related
Mar 26, 2014
I need to display button based on the condition in xhtml page.
using JSF2 & richface 4.0
<c:forEach items="#{empList}" var="emp">
How to check condition like empList.size > 0 in xhtml?
if list is having value, need to show buttons.
View Replies
View Related
Jun 12, 2014
I what to check if value is not equal to CharSequence value
I try this but getting error:
Java Code:
private CharSequence testvalue = "";
if (!isEqualTo("BCDEF".contains(testvalue))){
}
public boolean isEqualTo(String s_src, String s_compareTo) {
boolean flag = false;
[Code] .....
View Replies
View Related
Jul 14, 2014
I just want to check that the given PDF file is 3D PDF or normal PDF file. how can I do this in JAVA?
View Replies
View Related
Apr 15, 2015
What I'm trying to do is say if the array contains the character a, then output: this letter is already in the array. I tried
if(arrayList.contains(a)) {
System.out.println("This is already in the array!");
}
but it's not working. What should I use?
View Replies
View Related
Sep 23, 2014
My goal is to make a working spell check program.I have made some progress, but the more I test, the more issues I get and I continue to edit the algorithm.
import java.util.*;
import java.io.*;
public class SpellCheckTestClass{
public static void main(String [] args) throws IOException{
ArrayList<String> englishwords = new ArrayList<String>();
ArrayList<String> suggestions = new ArrayList<String>();
Scanner in = new Scanner(System.in);
String entry = in.next();
[code]....
View Replies
View Related
Nov 22, 2014
I am currently trying to write a method for checking to see if an "agent" in a cell (place in a 2d array) is satisfied. So, the assignment is a 2D array that can have a blank space, an O, or a X as a character that fills a particular space. An agent is satisfied if it has similar characters around it in a percentage that is higher than the threshold. For example, if the threshold was 60% and a cell that had an X in it, had 3 X's around it and 2 O's, then it would be satisfied because 3/5>=60%. For my code, I tried using if and else statements to isolate circumstances in the corner of the grid, the edges, and everything in between.
public static boolean isSatisfied(char[][] tissue, int row, int col, int threshold){
char check= tissue[row][col];
if (check==' '){
return true;
}
else{
int countx = 0;
int count = 0;
[Code] ....
View Replies
View Related
Apr 9, 2014
the program runs fine with exception of color background change.. dont laugh at code.
package chapter7;
import java.awt.*;
import java.awt.event.*;
[Code].....
View Replies
View Related
Jan 24, 2014
I am using form based, declarative security approach. And, when some user, on login form enters user credentials (username and password), he is being redirected to certain/secured jsp page.
Part of that page content is:Hello <%=request.getUserPrincipal().getName().toString()%> You are able to view this page because you are authorized user.You can see that this is implemented using JSP scriptlet. And this works. I would like to use JSTL instead of scriptlet.
So, instead of scriptlet, I put this JSTL code: <c:out value="${requestScope.userPrincipal.name}"/>, but not getting user's username with it. Basically, I don't clearly understand where and how are these objects/user credentials being stored with Form based JAAS.
I would like on JSP page to check if some user is already logged in. So, if there is logged user to display user's name (also with JSTL).Something like this:
<c:if test="${not empty sessionScope.userPrincipal}">
User <c:out value="${sessionScope.userPrincipal.name}" />
</c:if>
Here I tried with sessionScope but still not getting anything.
View Replies
View Related