Find Future Dates Switch Program

Sep 19, 2014

//Program prompts user for today's day (0-6) and a number for future date.

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

[code]...

I was thinking of a second string for futureDate to print after: "the future day is " line.

View Replies


ADVERTISEMENT

Report Employee Time Clock Cannot Find Corresponding Dates In And Out

Mar 8, 2014

I have this assignment to build an employee time clock. By using a menu you can enter an employee, enter punch in and out, and report.When I created the punch screen I wrote the in and out records to a file. Because there can be several employees punching in or out the file wrote each occurrence on different lines. Now I am attempting to write the report which you enter an employee Id and loop through the file to find the in and out date and then calculate the time (hours worked). I loaded the file into an Arraylist but now I cannot figure out how to loop through find the In and Out date - calculate the hours worked and then move on to the next day. here is the format of the file - employee id, place holder I or O, date, time, day. and sample

111221111i3/2/145:10 PMSunday
111221111o3/2/145:10 PMSunday
111331111i3/2/145:25 PMSunday
111331111o3/3/1412:47 PMMonday
111221111i3/3/1412:48 PMMonday
111221111o3/3/142:23 PMMonday
111441111i3/4/141:30 PMTuesday

[code]....

here is my code from the main screen.

public static void displayPunches()
throws FileNotFoundException, IOException, ParseException {
boolean isValid = false;
String choice = "y";
String emp = Validator.getLine(sc, "Enter I -Individual or A -All ");
if (emp.equalsIgnoreCase("A"))

[code]....

View Replies View Related

While And Nested Switch EStructures - Cannot Find Symbol

Nov 28, 2014

I was trying something in java, while coding this method i used a do...while and a nested switch estructures... The problem is that when i try to compile it the only error I have is:

Album.java:87: error: cannot find symbol
while( seguirLoop == true );
^
symbol: variable seguirLoop
location: class Album
1 error

And here is the code:

//Metodo seleccion de modo
public void SeleccionDeModo()
{
do
{
//Permite al usuario seleccionar metodo de escucha
System.out.println("Seleccione metodo de escucha:");
System.out.println("0 = Secuencia normal");
System.out.println("1 = Reproduccion aleatoria");
 
[code]...

I have already saw some other examples, but I just cant find the error here..

View Replies View Related

How To Write A Program To Record Names And Dates

Mar 2, 2014

I want an app that I can use to save the name, address, item sold, subject discussed and date that I visited someone - in a job similar to a sales rep. I would like to be able to choose how to sort the info so that if I sort by date I can see who hasn't been visited for the longest and start there. If I think of someone's name then of course I want to sort by name.

One of my friends says he works with "php"[? I'm still learning these terms] and everything happens online. I would like it to be an android app so it can be done without an internet connection ....

View Replies View Related

Program That Returns Number Of Days Between Two Dates - Incorrect Values

Mar 24, 2014

How to get used to program control statements. This is an attempt to write a program that returns the number of days between two dates. Sadly, it give incorrect values.

public class DaysBetweenDates {
public static boolean isLeapyear(int year) {//This method will determine if a year is a leap year or not
boolean isTrue=false;
if(year%4==0 && year%100!=0) isTrue=true;
else if(year%400==0) isTrue=true;
return isTrue;

[Code] ....

View Replies View Related

Returning Future Value In Investment Application

Oct 26, 2014

I am having an issue returning my future value in an investment application. I think the issue is with /** Find total FutureValue */ getFutureValue() Here is the code:

public class Investment {
private double annualInterestRate;
private int numberOfYears;
private double InvestmentAmount;
private java.util.Date InvestmentDate;

/** Default constructor */
public Investment() {
this(2.5, 1, 1000);

[Code] .....

View Replies View Related

Program Calculator Using Switch Case

Oct 14, 2014

I am making a programme for a calculator to - Divide, multiply, add and subtract. I have the code written but when I am running it and trying to add it was for some subtracting ....

import javax.swing.JOptionPane;
public class calculator3 {
public static void main(String[] args){
String number1,number2,operatorstring;
double result=0,a,b;

[Code] ....

View Replies View Related

Cash Register Program For 5 Products Using Switch Or If Else Statement In Java

Dec 3, 2014

We're told to make a cash register program for 5 products using Java. It loops until "-1" is entered on the "Continue?" input dialog box.There should be a:

1. Main Menu - where the user will pick what to buy (one product at a time) like the sample code below and prompt the user if he will buy another product or not. If yes, the program will go back to the main menu to buy another product and if not, continue to the program. And it looks something like this: LEvFOwQ.png

2. Receipt - at the end of every transaction.

3. Daily Sales Report where it shows all receipts then grand total like:

Transaction 1

-subtotal

Transaction 2

-subtotal

and so on then,

GRAND TOTAL

4. Inventory Report where it shows the Items Available before the Selling, Items Sold, and Items Available after Selling in table format.

Below is the code for a simple cash register for only one product that I made but I need to upgrade it for it to work for 5 products. That code will serve as the basis for this program.make the switch or if-else statement for the main menu first and if I got it right I try doing the rest.

int userQty1 = Integer.parseInt(JOptionPane.showInputDialog(
"Product ID Product Name Product Quantity Product Price"
+prodID1 + " " +prodName1 + " " + prodQty1 + " " +prodPrice1 "
"
+ and so on until prod5));

[code].....

View Replies View Related

Writing A Program Using Switch Statement - Allow Users To Choose Item Of A Menu

Oct 5, 2014

Write a program using switch statement to allow users to choose an item of a menu. For example, the menu looks like the following.

File menu
1. Open
2. Close
3. Save
4. Exit
Enter your choice:

If you type 1, then your program should print out "Open is selected" (double quotes not included).

Notice:
(1) Using Scanner to get user choice;
(2) If the number user input is not in {1,2,3,4}, your program should let user know that.

Here's what I have:

public static void main (String[] args) {
int user = 1
switch (1) {
case value: 1
System.out.println ("Open is selected");

[Code] .....

View Replies View Related

How To Find If JVM Is 32 Or 64 Bit From Java Program

Jun 26, 2014

How to find if JVM is 32 or 64 bit from Java program....

View Replies View Related

Program To Find Repeated Words

Feb 5, 2014

I have made a program which finds the number of occurrence of the words. It is as follows :

public class B {
public static void main(String[] args) {
Map<String, Integer> mp = new LinkedHashMap<String, Integer>();
String s = "This is me tarun ohri This";
Scanner p = new Scanner(s);
int i = 0;

[Code] .....

Output is coming {This=0, is=1, me=1, tarun=1, ohri=1}

View Replies View Related

Write A Program That Find The Sum Of Two Numbers 62 And 99?

Jan 23, 2015

I have to write a program that find the sum of two numbers 62 and 99 and stores them in a variable named total. However, I have one error that I just can't get rid of and can't tell what it is. I'm using jGrasp and here's what it says:

Programming Challenge #5.java:14: error: class SumofTwoNumbs is public, should be declared in a file named SumofTwoNumbs.java
public class SumofTwoNumbs {
^
1 error
  ----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.

and here: is my code:

import java.util.Scanner; 
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
 /**
// This program has variable of several of the integer types.
public class SumofTwoNumbs {
public static void main(String[] args) {

[code]....

View Replies View Related

Program To Find Adjacent Value For -1 - No Output

Apr 25, 2015

I wrote a program that find adjacent value for -1 .ex:

input
1
3 3
1 2 2
1 1 -1
5 5 0

output
1

code:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication1;
import java.util.Scanner;

[Code] ....

View Replies View Related

Program To Find Miles Per Gallon

Jan 23, 2015

I have to write a program the calculates the MPG and display's the result on the screen. However, I have three errors I just can't seem to figure out. jGrasp points to the following error, but doesn't tell me what it is:

Programming Challenge #9.java:34: error: cannot find symbol
gallons = keyboard.nextInt();
^
symbol: variable keyboard
location: class MPG
3 errors
 
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.

My code is as follows:

import java.util.Scanner;
 /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
 
// This program has variable of several of the integer types.
 public class MPG {
public static void main(String[] args) {

[Code] ....

View Replies View Related

Program To Find If Numbers Are Consecutive Or Not

Feb 23, 2014

im trying to do a program to find if numbers are consecutive or not! if they are consecutive i need a true as a return and a false when they are not... i did this program and im sure i did something wrong because i keep only true returns ..

Example: (3,5,7) (1,2,2) (7,7,9) should return a false!
Java Code: import java.util.*;
public class Consecutive{
public static void main (String [] args){
Scanner console= new Scanner(System.in);
System.out.println("Enter three numbers");
String numbers = console.nextLine();
System.out.println( "The numbers (" + numbers + ") is '" + consecutive( numbers ) + "'" );
}//end of main

[code]...

View Replies View Related

Find Language Of Given Text In A Program

Jan 18, 2014

I want a java program to find the language of a given text in a program

For Example: If user enters Hello World it should say its english language

And if he enters a spanish language as a input it should say its spanish language and so on....

View Replies View Related

How To Find Out Minimum JRE Requirement For Java Program

Jan 26, 2014

I finished a game in Java and sent it to a friend. Launching the program in my computer worked just fine.

But he got this error : "Could not find the main classs: Main. program will exit"

My JRE version is the most updated one. His JRE was version 1.6. He updated his JRE, and the problem was solved.

This is a bit worrying for me, because as far as I know, 1.6 isn't a very old version of the JRE. It's not the most recent one, but not that old.

This is worrying because I'm planning on sending my game to a lot of friends, and trying to distribute it on the internet.

A lot of people don't have the most updated JRE. And they are mostly non-programmers, so I can't expect them to update to the newest version of Java upon downloading my game. They might not know what Java is, even though they got it on their computer, and upon receiving an error, they'll just give up on the game.

If my game wouldn't work with a significantly old JRE, that would be reasonable. It's part of the nature of working with Java. But the fact that a relatively updated JRE, 1.6, doesn't work with my game, is worrying.

*(Please note: My game isn't implementing anything "special". Swing and KeyBindings are the 'newest' additions to Java that I can think of inside my game)*.

In short, I'd like to know that my game works on most of the computers it tries to run on. Knowing that it doesn't work on a relatively new JRE, is worrying.

So I have two questions:

1. Is it normal, for a Java program, to have such "high" demands for the JRE version? Do a lot of Java games demand at least version 1.6 of the JRE? Is this common?

2. How can I find out the minimum JRE version requirement for my program? Is there a methodical way to do this, or do I just have to go through all the libraries I use in my game and figure out what's the JRE release version for each one?

View Replies View Related

Command Prompt Can't Find Hello World Program

Jun 7, 2014

I just created a Hello World program in Notepad, but command prompt still can't find it even when ran as administrator. I've even tried to use command line to run Hello World programs I've created with Eclipse but it still doesn't work. Here's proof I have JDK setup as PATH:

I've even tried having the JRE as path but that still doesn't solve my problem. I'm really trying to learn Java programming but this problem is holding me back.

View Replies View Related

Program That Find Minimum Value In Array Of Integers

Feb 3, 2014

I'm required to create a program that finds the minimum value in an Array of integers.

Here is my approach :

public class Person {
public static void main(String [ ] args){
int theArray[]=new int [10];
int result = 0;
for (int i:theArray){
if (i < Integer.MAX_VALUE)

[Code]...

I can't really progress from this position. I keep getting told to change the return type to int on main method, then when i do it says change it to void..

View Replies View Related

Sudoku Checker Program - Cannot Find Symbol

Jul 9, 2014

I can't get the code to compile for the driver every time i get an error message saying

SudokuCheckerTest.java:28: error: cannot find symbol
foo.displayGrid(grid);
^
symbol: variable grid
location: class SudokuCheckerTest
SudokuCheckerTest.java:29: error: cannot find symbol
foo.getGrid(grid);

[Code] .....

4 errors

Java Code :

import java.util.Scanner;
public class SudokuChecker{
public SudokuChecker(){
// displays intro code and initializes the array grid as well as using method calls.
Scanner in = new Scanner(System.in);
int [][] grid = new int [4][4];
displayGrid(grid);

[Code] ....

View Replies View Related

Could Not Find Main Class - Program Will Exit

Jan 24, 2015

This is my first java program,i am using eclipse IDE-----

package day1.example;

public class MyFirstJava {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("hi");
}
}

When i saved it,it shows no error.when i run it then a pop-up says "could not find the main class.the program will exit" and in the console it says---

java.lang.UnsupportedClassVersionError: day1/example/MyFirstJava : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)

[Code] ......

View Replies View Related

Days Between Dates

Nov 3, 2014

Compile errors. This is the code I have:

import java.util.Scanner;
import java.io.*;
public class LeapYear {
public static void main(String[] args) throws IOException {
int month1, day1, year1, month2, day2, year2;

[Code] ....

This is the compile error I'm getting:

The total number of days between the dates you entered are: 76882
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:909)
at java.util.Scanner.next(Scanner.java:1530)
at java.util.Scanner.nextInt(Scanner.java:2160)
at java.util.Scanner.nextInt(Scanner.java:2119)
at LeapYear.main(LeapYear.java:16)

View Replies View Related

How To Calculate Difference Between Two Dates

Oct 19, 2014

I have been tasked with creating an invoice (school assignment). Part of the calculations is creating an interest depending on the amount of days between the current date entered, and invoice date entered (The program prompts the user to enter both the current and invoice dates by asking for the day, month and year).

We are also supposed to set the contructor to a default date of 1/1/1900.. but I don't know how or where to code that.

How to calculate the difference between the CurrentDate and Invoice. I have displayed the dates to the user as follows.

public void displayDate() {
System.out.println("
Today's Date: " + month + "/" + day + "/" + year);
}
public void displayInvDate() {
System.out.println("
Invoice Date: " + invMonth + "/" + invDay + "/" + invYear);

View Replies View Related

Dates Parsing Related

Feb 1, 2014

I have a date sch_date_time=01/02/2014 08:00

And when i am doing SimpleDateFormat sdf = new SimpleDateFormat("dd/mm/yyyy HH:mm");

date1 = sdf.parse(sch_date_time);

when i am printing date1 it is printing as Wed Jan 01 08:00:00 IST 2014,but it should be printed as Sat Feb 01...

View Replies View Related

Number Of Days Between Dates

Jun 29, 2011

I'm trying to write a program that computes the number of days between two dates. How I can achieve this. I'm quite sure I'm supposed to use the Calendar class.

View Replies View Related

How To Use FormattedFields For Inserting Dates

Feb 10, 2014

I know the below code is supposed to format the FormattedTextField but it doesn't seem to do anything to the form (shown in the picture below). I was wanting, when the form loaded: the text field to look something like this

00/00/2014 - 00:00 am

Where the user is able to

- enter datelike information around the symbol separators ( / or : )

- But where the user could not remove these symbol separators

Code:

package datefield;
import javax.swing.JFormattedTextField;
import javax.swing.text.DateFormatter;
public class NewJFrame extends javax.swing.JFrame {
public NewJFrame() {
initComponents();

[Code]...

View Replies View Related







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