Program To Determine Max Amount Of Units Sold And Display It In Dialog Box

Feb 9, 2014

I am trying to write a program that basically determines the max amount of units sold and displays it in a dialog box. Also, the program will display the winning sales associate out of 10. I have wrote the program successfully so far and I can see the maximum number of units sold displayed in the dialog box, but I cannot seem to link the winning sales person.

Here is the code I have typed so far.

//Program to find maximum of three number

import javax.swing.JOptionPane;
import java.util.Scanner;
public class Sales
{
public static void main (String[] args)
{
//Declare variables
int num1, num2, num3, num4, num5, num6, num7, num8, num9, num10;
int large;
int winner;

[Code] ......

View Replies


ADVERTISEMENT

Java Program Which Would Display A Message Dialog Box Stopped Working

Mar 16, 2014

I have a java program which would display a message dialog box. The problem is it would stopped working before even displaying the message dialog box. This is my code.

import javax.swing.JOptionPane;
public class HelloDialog {
public static void main(String [] args) {
JOptionPane.showMessageDialog(null, "Hello World!");
}
}

There is a pop-up window which would say "Java(TM) Platform SE binary has stopped working." I am using textpad. What should I do with this?

View Replies View Related

Making A Program That Could Convert Metric Units Into American System

Aug 31, 2014

I just started programming yesterday, and I have been making little programs to learn some algorithms and the syntax of java. I tried making a program that could convert metric units into the American system. Whenever I try to compile the code, it shows up as an "incompatible type" error. I know this is probably a very obvious answer to most of you, but I can't figure it out.

import java.util.Scanner;
public class MetricToAmerican
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
System.out.println("fWhat measurement would you like to convert into US system?
celsius, meter, or kilogram ");

[code]....

View Replies View Related

JSP :: How To Display Amount In Indian Format

Apr 30, 2014

i want to display a amount in indian currency format,

i.e=10000000=this iwant show is=1,00,00,000 rather than 10,000,000

View Replies View Related

How To Display Amount Paid By User And Show Balance

May 3, 2015

I've four classes object. I don't know how to display the amount paid by the user, and show the balance. The calculate button just show the total amount. Do I have to create another object class? And I've to show the bills too.

This is my 1st Frame

import javax.swing.*;
import java.awt.*;
//titlepanel class displays a title in a panel
public class TitlePanel extends JPanel {
public TitlePanel() {
JLabel title = new JLabel();

[Code] .....

View Replies View Related

Calculate Total Amount Paid And Display It - NULL Error

Dec 10, 2014

Exception in thread "main" java.lang.NullPointerException
at ShoeStore.calculateTotal(ShoeStore.java:103)
at ShoeStore.main(ShoeStore.java:88)

This is the error when program is ran. The program is supposed to calculate the total amount paid for all shoes and display it.

import java.util.Scanner;
 public class ShoeStore
{
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
String shoe_Name, nameStore, type;
int size, shoeAmount;
double sellingCost;
 
 [Code] .....

View Replies View Related

JSF :: Display Dialog Upon Session Timeout On Ajax Calls

Feb 19, 2013

I am new to JSF and I am working on handling session timeout for a JSF application. I am trying to get the code to work for ajax calls and not able to achieve that so far. I have tried two approaches:

Approach 1: SessionListener (for cleanup work) and SessionFilter (for filtering every request and checking if session timed out)

My Code snippet of doFilter() of SessionFilter:

if ((request instanceof HttpServletRequest)
&& (response instanceof HttpServletResponse)) {
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
HttpServletResponse httpServletResponse = (HttpServletResponse) response;
// is session expire control required for this request? (not required for home page or timeout page or JSF resources)
if (isSessionControlRequired(httpServletRequest)) {

[Code] .....

Both these approaches work for non-ajax POST calls but not for ajax calls. When I run my app in debug mode, I can step through all the statements for ajax calls also, which gives me an idea that the control does come to my code, executes it but for some reason, nothing happens on the UI.

I have been trying to redirect user to a timeout page but the ideal thing would be to display a JSF dialog and upon hitting 'OK' take user to Home Screen (My app does not have a login screen.) I have a basic questions also, is view expiring exactly same as session timeout?

View Replies View Related

Swing/AWT/SWT :: Progress Bar Dialog Sometimes Doesn't Display Components

Mar 7, 2014

I wish to display a progress bar during a lengthy file translation process. When I created a ProgressBar class to do this and tested it with a short test program, it seemed to work fine. But when I add my ProgressBar class to a package containing various other classes, put that package in a jar file, and then execute the class using the progress bar from a menu in my main program, the frame of the progress bar shows up with the appropriate caption but the JLabel, JProgressBar, and JButton are not displayed. I have gone over my code numerous times and checked that the ProgressBar class constructor is getting the proper arguments.

// package gov.nasa.jpl.ephemeris;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* Progress bar with message text above the bar and a Cancel button below it
*/
public class ProgressBar extends JFrame {
private boolean _cancelled = false;
private JProgressBar _progressBar = null;

[Code] ....

I have also been wondering whether I need a separate instance of the border for each panel, or whether I can just create one instance and use it for all three panels.

View Replies View Related

Basic GUI Calculator - Display Amount Of Commission And Total Annual Salary In Dollar Format

Apr 28, 2014

So, I am supposed to write a program that calculates the total annual compensation for a salesman using user input for the salary, sales, and commission rate (list of 3 predefined commission rates. have to display in dollar format the amount of commission and total annual salary.

CommCalc class

public class CommCalc
{
//attributes of class, stored data
private double sales;
private double salary;
private double rate;
//and a total field? beware stale data.
//store sales argument from sales field
public void setSales(double sal)

[Code] ....

I know that i have to fix some of the semantics . I have this code that I made earlier, is there an easy way to make it into a GUI interface? Or will I have to go throughthe code lines to add the JOptionPane? And I am a little confused on how to make a list (array) for the commission rate.

View Replies View Related

How To Get A Program To Repeat X Amount Of Times Automatically

Oct 27, 2014

Ii am trying run a do while loop on java a specific amount of times for example if i were to type in "Enter number of years" and enter 4. i need the loop to execute 4 times or if i said 6 times then i would be 6. the program i have repeats it and takes it back to reentering "Enter number of years" i need it to execute by its self x amount of times. here is what i have so far

System.out.println("Enter the number of years: ");
years = keyboard.nextInt();
rainfall = generator.nextInt(10) + 1;
System.out.println("Year " + "rainfall amounts were");;
for (int months = 1; months <= 12; months++)

[Code]...

View Replies View Related

POS System / Printing Receipt When Items Sold - ArrayList Out Of Bound

Nov 8, 2014

Basically I am trying to make a POS system and need a way to print a receipt whether there are 1 items sold or 50. So I used a Arraylist. This is the format for the printer that is needed:

printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, " 2 200 Tx Hashi Chop Sticks" + LF);

This is what I tried to do:

ArrayList<String> receiptLine = new ArrayList<>();
public void captureSales(){
receiptLine.add("Test");
System.out.println("Size of the receipt list is: "+receiptLine.size());
System.out.println("Element at index 1: " + receiptLine.get(0));

printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, " " + receiptLine.get(0) + LF);

Error:

Size of the receipt list is: 1
Element at index 1: Test
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

View Replies View Related

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

Program That Prompts The User To Enter Loan Amount And Years

Oct 21, 2014

so I had to make a program that prompts the user to enter a loan amount and the years for the loan and I have the conversions and everything my only issue is that when the chart pops up it just looks like a bunch of numbers and its missing the column headers

for example

Interest Rate Monthly Payment Total Payment

import java.util.Scanner; 
public class InterestRate { 
public static void main(String[] args) { 
double monthlypayment = 0; 
double totalpayment = 0; 
Scanner input = new Scanner(System.in);
System.out.println("Enter Loan Amount");

[Code]...

View Replies View Related

Simple Program Giving Negative Result For Amount Of Calculations Done

Mar 5, 2014

Why this extremely simple program seems to be giving me a negative value for amount of calculations done within one minute ( Just using it as a bit of fun to see how different computers in the office perform).

Java Code:

class Benchmark {
public static void main(String[] args) {
long endTime = System.currentTimeMillis() + 60000;
int count = 0;
for (int i = 0; System.currentTimeMillis() < endTime; i++) {
double x = Math.sqrt(System.currentTimeMillis());
count = i;
}
System.out.print(count + " calculations per minute");
}
} mh_sh_highlight_all('java');

I am getting results between -2.1billion and -3.4billion which to me would make sense since they are not the best computers in the world but I would be expecting a positive value?

View Replies View Related

Allowing User To Determine When A Program Is Stopped?

Nov 8, 2014

I was tasked with building a program that counts vowels in a phrase or word. I have this working properly, but the problem arises in the next situation. Here is my code:
 
Scanner userInput = new Scanner(System.in);
int userDecision;
String Choice;
String Phrase;
int vowelCount = 0;
System.out.println(" This program will count the number of vowels in it.

[Code] ....

As you can see, I used a 'for' statement to declare how long the program should run. However, I need the user to be able to say when it ends. For example, at the end of the program it must say "There are ______ number of vowels in your word. Please press '1' to run the program again, or any other number to exit."

I understand a do-while loop is needed here, but every time I try and create an adequate loop with no logic errors, I either break my existing code, or the program does not work correctly.

Basically, my question is, what is the best way to perform this task? Is a do-while loop necessary, or is there a better way?

View Replies View Related

Write A Program To Determine Sum Of Following Harmonic Series For A Given Value Of N

May 9, 2014

write a program to determine the sum of the following harmonic series for a given value of n:1+1/2+1/3+.............................+1/n the value of n should be given interactively through the keyboard.

View Replies View Related

Java Program That Specifies Three One-dimensional Arrays Names Price / Amount And Total

Dec 2, 2014

Recently I have missed a few weeks of my class due to family emergencies. Because of this I have missed very important lectures. My professor has assigned me the following assignment:

Prices Write a Java program that specifies three one-dimensional arrays names price, amount, and total. Each array should be capable of holding 10 elements. Using a loop, input values for the price and amount arrays. The entries in the total array should be the product of the corresponding values in the price and amount arrays. After all the data have been entered, display the following output:

Total Price Amount

==== ==== ======

Under each column heading display the appropriate value.

I know how to display everything using printf, how to create the actual arrays and define the array size, but I am confused on how and what loop to use and how to construct it. This is what I have managed to write up so far:

import java.util.Scanner; // Imports the Scanner class
import java.text.DecimalFormat; // Imports the DecimalFormat class

public class Prices
{
public static void main(String [] args)
{
double[] price = new double[10];
double[] amount = new double[10];
double[] total = new double[10];

// Create a new Scanner object
Scanner keyboard = new Scanner(System.in);
} //End of main method
} // End of public class

View Replies View Related

Program That Will Determine Total Weight And Center Of Gravity

Sep 18, 2014

You have been given the job of writing a program to assist pilots who fly the Beechcraft Starship-‐‑1 executive aircraft.As with any airplane, it is essential that the pilot know the total weight of the loaded plane at takeoff and its center of gravity. If the plane weighs too much, it won'ʹt be able to lift off. If the center of gravity is outside the limits established for the plane, it might be impossible to control. Your task is to write a program that will determine the total weight and center of gravity of this plane

Inputs: The number of crew members, number of passengers, weight of the forward baggage compartment contents, aft baggage compartment contents weight, and the amount of fuel in gallons are to be accepted as INTEGER values in the order stated. Be sure the input values are within acceptable ranges

Outputs:You must echo the input values, annotated with their appropriate names,calculate and display the total weight, and the center of gravity.

View Replies View Related

Program To Determine Number Of Days In A Year Up To And Including The Current Day

Nov 23, 2014

So basically we have this question to do : Write a method dayNumber that determines the number of days in a year up to and including the current day. The method should have three int parameters: year, month, and day. If the value of any parameter is invalid, the method should print a warning message and return the value zero. The table gives some examples of the action of the method. Accept any non-negative year as being valid. You may want to assume the existence of a method numberOfDays that returns the number of days in a given month of a given year. And you should have a method call isLeapYear, if the user enter a year that is a leap year.

This is what I did so far:

class dayMonthYear {
public static void main(String[] args) {
System.out.println("Enter a year");
int year = In.getInt();
System.out.println("Enter the month for '1' to be January - '12' to be december");

[Code] ....

It works and compiles but my problem is that: let say I enter "12" for December and December has 31 days, so what my program will do since December has 31 days, it thinks each month has 31 days and add them up which will give me 372 when it's suppose to give me 365. How do I make it that it won't do that and that it will work if the year is a leap year too.

View Replies View Related

Different Units In Calculation

Sep 8, 2014

I have a maths application I am working on in java. This is more related to maths but there could be some here who have worked with calculations like this in their java project.

One could convert from degree to radians and from mph to knots. Could one convert from knots to degree or from mph to degree?

View Replies View Related

Correct Units And Nested If Statements

Feb 19, 2015

How I am supposed to set up the units for my program, and how to correctly display them in the console. Here is a description of my program.

To display the nonzero denominations only, using singular words for single units such as 1 dollar and 1 penny, and plural words for more than one unit such as 2 dollars and 3 pennies. You must use nested if statement when displaying the output.

Sample run:
Enter an amount in double, for example 11.56: 1.56
Your amount 1.56 consists of
1 dollar
2 quarters
1 nickel
1 penny

View Replies View Related

Accurately Converting Units Involving Extremely Small Numbers?

Jun 16, 2014

I need to convert units accurately. Some of these units include angstroms (0.1nm) and astronomical units or light years. I can't seem to accurately perform these equations (probably mostly because of lack of a proper conversion formula). For example:

1 angstrom = 1.79985601 × 10^-14 leagues (or, 0.00000000000001799856 leagues).

To perform the conversion right now, I'm simply multiplying the angstroms by 0.00000000000001799856. However, inputting 55560000000000 (angstroms in one league) results in 0.9999999936. Why is this? Is it possible to work around it? I believe there's a term for the inability for a computer to process 1/3rd properly, but I can't remember what it's called - is that the problem?

I am using BigDecimals for all equations.

Edit: a mod can change the title if they think another is more fitting.

View Replies View Related

How To Do Subtraction Quiz Program Using Input Dialog Quiz

Oct 14, 2014

How can I do a subtraction quiz program using input dialog quiz?

View Replies View Related

Program That Display GPA With Message

Mar 21, 2015

As a part-time student, you took two courses last term. Write a Java program that calculates and displays your grade point average (GPA) for the term. Your program should prompt the user to enter the grade and credit hours for each course. This information should then be displayed with the lowest grade first, and the GPA for the term should be calculated and displayed. A warning message should be printed if the GPA is less 2.0 and a congratulatory message if the GPA is 3.5 or above.

View Replies View Related

Inventory Program - Display Information To GUI

Feb 28, 2015

I am trying to create a GUI with already existing code. My assignment is: Modify the Inventory Program to use a GUI. The GUI should display the information one product at a time, including the item number, the name of the product, the number of units in stock, the price of each unit, and the value of the inventory of that product. In addition, the GUI should display the value of the entire inventory, the additional attribute, and the restocking fee.

Where to start. The text book does not cover a GUI that displays this type of information rather it just displays graphics. I would like to create a separate class that holds the GUI information just to make everything flow better. I have provided my current code below:

Java Code:

// ProductTest.java
// by JakeB
public class ProductTest {
// main method begins
public static void main(String[] args) // begin main {
myGUI display = new myGUI();
display.setVisible(true);

[Code] .....

This is all I have for the GUI. I am at a total loss and I am behind 2 weeks now. I cannot move forward until I am able to get this done and the class ends next week.

View Replies View Related

Program That Will Have GUI Window And Display Image?

Jun 24, 2014

I am writing a program that will have a GUI window and displays an image when clicked on the image changes and clicked on again the image changes once more. Here is what i have.

package ButtonLab;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

[Code]....

The issue i am having is when i run it the window pops up but with no images. The images wont load, I have tried to use the c: path to the image also.

View Replies View Related







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