"If statement" problem in simple code?
Hi,
I am writing a simple homework program however am having some major problems with my "If" Statement and can not figure out why. I want my program to return a different variable if true yet it always says the statement is false. I Have it set up now in the test stage so that if false it prints out the two comparative variables in the Console and even though both variables are the same it still always says its false. Any ideas? Here are my two simple classes below. Thanks. And yes i know it doesn't go through the whole loop, it should not have to because in this test state the first variable it compares should be true.
import java.util.StringTokenizer;
public class PhoneList {
private static final String PHONE_BOOK = "mom:860-192-9876,bill:654-987-1234,mary:123-842-1100";
public static String getPhoneNumber(String name) {
// StringBuffer result = new StringBuffer();
StringTokenizer st = new StringTokenizer(PHONE_BOOK, ",:");
String[] tokens = new String[PHONE_BOOK.length()];
int c = 0;
String current = "";
while (st.hasMoreTokens()) {
current = st.nextToken();
tokens[c] = current;
c = c + 1;
for (int i = 0; i < c;) {
if (name == tokens) {
return "YES";
else {
return tokens[i] + "|" + name;
// i=i+1;
return "NO";
public class Interface {
public static void main(String[] args) {
String hi = "mom";
System.out.println(PhoneList.getPhoneNumber(hi));
Hey,
Thanks guys I got that working, my question now is, whats the best way to input a String into the console from the user and have the string stored as a string variable? I know how to do it for an INT and after reading online can do stings with the try / catch method but I want a more simple better way such as the way I do INTs...
import java.util.Scanner;
int choice;
Scanner in = new Scanner(System.in);
choice = in.nextInt();
Any easy way to do this for Strings? Thanks
Similar Messages
-
Hi,
I bought a book yesterday and I was able to open it in my vista machine. I have a second computer and I can't open my book there. I get this error:
Adobe DRM Error
System: 8
State: 4
Class: 65
Code: 59
Message:
VE error 59
--- end ---
I already downloaded Adobe Digital Editions 1.5 beta 2, and went back to acrobat reader 6, activate from aractivate.adobe.com, but nothing seems to work. What can I do?System 7, code 31 is always a networking problem. Meaning something on your network is preventing the book information from getting to the rights-management server (or from the rights-management information getting sent back)
You can check firewalls, security software, etc to see where the blockage might be, or work with your network admins if you have them. See 'Error "Adobe DRM Error" when you activate Digital Editions or access an eBook" at http://www.adobe.com/go/kb402747
Regards,
Bentley Wolfe
Senior Support Engineer, Flash/Flash Player/Digital Editions
Adobe -
How to replace huge decode statements with lookups to some simple code/key
I have a legacy PL/SQL application, composed of many very huge decode statements. And the most terribe one is that the guys who develops the application left the company now, leaves no documentation.
We are trying to read and understand those PL/SQL programs, and I'm asked to replace those huge decode statements with lookups to some simple code/key tables? But I have no idea about how to design such code/key tables. Is there any one who has similar experience may help me? Besides code/key tables, any idea will be welcome.
Thank you very much!Not sure what your data looks like but sometimes decode can be replaced with more appropriate functions, ie;
SQL> with t as (
select 'DAY' a, 30 b, null c, null d from dual union all
select null a, null b, 'MONTH' c, 12 from dual)
select coalesce(b,d)
from t
COALESCE(B,D)
30
12
2 rows selected.
SQL> with t as (
select 'DAY' a, 30 b, null c, 0 d from dual union all
select null a, 0 b, 'MONTH' c, 12 from dual)
select greatest(b,d)
from t
GREATEST(B,D)
30
12
2 rows selected. -
I am doing a question in which I have to make a simple ATM program that can withraw and deposit money as many times as the user wants. To exit the program the user has to hit "x". I have to use a switch statement. Im getting incompatible type errors after compiling it. Can anyone help me? Sorry if the formattings not too good.
//ATM.java
//This program reads in a user's opening balance and performs a withdrawal or a deposit at the request of the user
import java.text.*;
public class ATM
public static void main(String args[])
int balance;
char withdrawal, deposit, choice;
//Ask for the opening balance
System.out.print("Please enter your opening balance");
balance=UserInput.getInt();
//Find out what the user wants done
System.out.print("What would you like to do? (Withdrawal, Depositor Exit(x))");
choice=UserInput.getChar();
switch(choice){
case "w":
while(balance>0)
System.out.print("How much would you like to withdraw?");
withdrawal=UserInput.getChar();
balance=balance-withdrawal;
System.out.print("Your remaining balance is " + balance);
break;
case "d":
while(balance>0)
System.out.print("How much do you wish to deposit?");
deposit=UserInput.getChar();
balance=balance+deposit;
System.out.print("Your new balance is " + balance);
break;
case "x":
System.out.print("Goodbye and thank you for using this program");
break;
default:
System.out.print("We were not able to process your request, please try again");
break;
}Type a reply to the topic using the form below. When finished, you can optionally preview your reply by clicking on the "Preview" button. Otherwise, click the "Post" button to submit your message immediately.
Subject:
Click for bold Click for italics Click for underline Click for code tags
Formatting tips
Message:
Add topic to Watchlist:
Original Message:
Switch statement problem
Xivilai Registered: Mar 3, 2007 9:52 AM Mar 3, 2007 10:06 AM
I am doing a question in which I have to make a simple ATM program that can withraw and deposit money as many times as the user wants. To exit the program the user has to hit "x". I have to use a switch statement. Im getting incompatible type errors after compiling it. Can anyone help me? Sorry if the formattings not too good.
//ATM.java
//This program reads in a user's opening balance and performs a withdrawal or a deposit at the request of the user
import java.text.*;
public class ATM
public static void main(String args[])
int balance;
char withdrawal, deposit, choice;
//Ask for the opening balance
System.out.print("Please enter your opening balance");
balance=UserInput.getInt();
//Find out what the user wants done
System.out.print("What would you like to do? (Withdrawal, Depositor Exit(x))");
choice=UserInput.getChar();
switch(choice){
case 'w':
while(balance>0)
System.out.print("How much would you like to withdraw?");
withdrawal=UserInput.getChar();
balance=balance-withdrawal;
System.out.print("Your remaining balance is " + balance);
break;
case 'd':
while(balance>0)
System.out.print("How much do you wish to deposit?");
deposit=UserInput.getChar();
balance=balance+deposit;
System.out.print("Your new balance is " + balance);
break;
case 'x':
System.out.print("Goodbye and thank you for using this program");
break;
default:
System.out.print("We were not able to process your request, please try again");
break;
} -
What is the problem with the code?
Hello, the following is a segment of code that I have written recently:
IF DATA+1(5) <> TEXT-035.
CATCH SYSTEM-EXCEPTIONS WEIRD_ERROR = 4
OTHERS = 8.
END CATCH.
ENDIF.
When I tried to compile the code, it says:
Unable to interpret "SYSTEM-EXCEPTIONS". Possible causes: Incorrect spelling or comma error.
May I know where is the problem with this code? Thanks a lot!
Regards,
AnyiHere is a list of the system exceptions.
Alphabetical List of Catchable Runtime Errors
,,ADDF_INT_OVERFLOW
Overflow in addition with type I ( ADD ... UNTIL / ADD ... FROM ... TO)
,,ASSIGN_CASTING_ILLEGAL_CAST
The offset and type of the source field and the target type do not match exactly in the components that are strings, tables, or references.
,,ASSIGN_CASTING_UNKNOWN_TYPE
The type specified at runtime is unknown.
,,BCD_FIELD_OVERFLOW
Overflow in conversion or arithmetic operations (type P with specified length)
,,BCD_OVERFLOW
Overflow in conversion or arithmetic operation (type P)
,,BCD_ZERODIVIDE
Division by 0 (type P)
,,CALL_METHOD_NOT_IMPLEMENTED
Call of a non-implemented interface method
,,COMPUTE_ACOS_DOMAIN
Invalid call of mathematical function ACOS
,,COMPUTE_ASIN_DOMAIN
Invalid call of mathematical function ASIN
,,COMPUTE_ATAN_DOMAIN
Invalid call of mathematical function ATAN
,,COMPUTE_BCD_OVERFLOW
Overflow in arithmetic operation (all operands type P)
,,COMPUTE_COSH_DOMAIN
Invalid call of mathematical function COSH
,,COMPUTE_COSH_OVERFLOW
Overflow in mathematical function COSH
,,COMPUTE_COS_DOMAIN
Invalid call of mathematical function COS
,,COMPUTE_COS_LOSS
Result of COS function is inexact
,,COMPUTE_EXP_DOMAIN
Invalid call of mathematical function EXP
,,COMPUTE_EXP_RANGE
Over- or underflow in mathematical function EXP
,,COMPUTE_FLOAT_DIV_OVERFLOW
Overflow in division (type F)
,,COMPUTE_FLOAT_MINUS_OVERFLOW
Overflow in subtraction (type F)
,,COMPUTE_FLOAT_PLUS_OVERFLOW
Overflow in addition (type F)
,,COMPUTE_FLOAT_TIMES_OVERFLOW
Overflow in multiplication (type F)
,,COMPUTE_FLOAT_ZERODIVIDE
Division by 0 (type F)
,,COMPUTE_INT_ABS_OVERFLOW
Integer overflow when calculating the absolute value
,,COMPUTE_INT_DIV_OVERFLOW
Integer overflow in division
,,COMPUTE_INT_MINUS_OVERFLOW
Integer overflow in subtraction
,,COMPUTE_INT_PLUS_OVERFLOW
Integer overflow in addition
,,COMPUTE_INT_TIMES_OVERFLOW
Integer overflow in multiplication
,,COMPUTE_INT_ZERODIVIDE
Division by 0 (type I)
,,COMPUTE_LOG10_ERROR
Invalid call of the mathematical function LOG10
,,COMPUTE_LOG_ERROR
Invalid call of the mathematical function LOG
,,COMPUTE_MATH_DOMAIN
Invalid call of a mathematical function
,,COMPUTE_MATH_ERROR
Error executing a mathematical function
,,COMPUTE_MATH_LOSS
Result of a mathematical function is inexact
,,COMPUTE_MATH_OVERFLOW
Overflow of a mathematical function
,,COMPUTE_MATH_UNDERFLOW
Underflow in a mathematical function
,,COMPUTE_POW_DOMAIN
Invalid argument when raising powers
,,COMPUTE_POW_RANGE
Over- or underflow when raising powers
,,COMPUTE_SINH_DOMAIN
Invalid call of the mathematical function SINH
,,COMPUTE_SINH_OVERFLOW
Overflow in the mathematical function SINH
,,COMPUTE_SIN_DOMAIN
Invalid call of the mathematical function SIN
,,COMPUTE_SIN_LOSS
Result of the function SIN is inexact
,,COMPUTE_SQRT_DOMAIN
Invalid call of the mathematical function SQRT
,,COMPUTE_TANH_DOMAIN
Invalid call of the mathematical function TANH
,,COMPUTE_TAN_DOMAIN
Invalid call of the mathematical function TAN
,,COMPUTE_TAN_LOSS
Result of the function TAN is inexact
,,CONNE_IMPORT_WRONG_COMP_LENG
Import error: A component in a structured type in the dataset has an incorrect length
,,CONNE_IMPORT_WRONG_COMP_TYPE
Import error: A component of a structured type in the dataset has an incorrect length
,,CONNE_IMPORT_WRONG_FIELD_LENG
Import error: A field in the dataset has an incorrect length
,,CONNE_IMPORT_WRONG_FIELD_TYPE
Import error: A field in a dataset has the wrong type
,,CONNE_IMPORT_OBJECT_TYPE
Import error: Type conflict between simple and structured data types
,,CONNE_IMPORT_WRONG_STRUCTURE
Import error: Type conflict between structured objects
,,CONVT_HEX_CONFLICT
Conversion conflict (Type X)
,,CONVT_NO_NUMBER
Value for conversion cannot be interpreted as a number
,,CONVT_OVERFLOW
Overflow in conversion (all types except type P)
,,CREATE_DATA_NOT_ALLOWED_TYPE
The statement CREATE DATA cannot be executed with a generic type.
,,CREATE_DATA_UNKNOWN_TYPE
The statement CREATE DATA cannot be executed with an unknown type.
,,CREATE_OBJECT_CLASS_ABSTRACT
Attempt to instantiate an abstract class.
,,CREATE_OBJECT_CLASS_NOT_FOUND
The class specified with a dynamic CREATE OBJECT was not found.
,,CREATE_OBJECT_CREATE_PRIVATE
Attempt to create an object of a class defined as 'CREATE PRIVATE'.
,,CREATE_OBJECT_CREATE_PROTECTED
Attempt to create an object of a class defined as 'CREATE PROTECTED'.
,,DATA_LENGTH_NEGATIVE
Invalid subfield access: Negative length
,,DATA_LENGTH_0
Invalid subfield access: Length 0
,,DATA_LENGTH_TOO_LARGE
Invalid subfield access: Length too large
,,DATA_OFFSET_NEGATIVE
Invalid subfield access: Negative offset
,,DATA_OFFSET_TOO_LARGE
Invalid subfield access: Offset too large
,,DATA_OFFSET_LENGTH_TOO_LARGE
Invalid subfield access: Offset + length too large
,,DATA_OFFSET_LENGTH_NOT_ALLOWED
Invalid subfield access: Type not appropriate
,,DATASET_CANT_CLOSE
Unable to close file. There may be no space left in the file system
,,DATASET_CANT_OPEN
Unable to open file
,,DATASET_NO_PIPE
The FILTER addition to the OPEN DATASET statement is not supported on the current operating system
,,DATASET_READ_ERROR
Error reading a file
,,DATASET_TOO_MANY_FILES
Maximum number of open files exceeded
,,DATASET_WRITE_ERROR
Error writing to a file
,,DYN_CALL_METH_CLASSCONSTRUCTOR
Attempt to call the class constructor
,,DYN_CALL_METH_CLASS_ABSTRACT
Attempt to call an abstract method
,,DYN_CALL_METH_CLASS_NOT_FOUND
Attempt to call a method of a non-existent class
,,DYN_CALL_METH_CONSTRUCTOR
Attempt to call the instance constructor
,,DYN_CALL_METH_EXCP_NOT_FOUND
Attempt to catch an unknown exception
,,DYN_CALL_METH_NOT_FOUND
Attempt to call an unknown method
,,DYN_CALL_METH_NOT_IMPLEMENTED
Attempt to call a method that has not been implemented yet
,,DYN_CALL_METH_NO_CLASS_METHOD
Attempt to call an instance method via a class
Attempt to pass a parameter with an incorrect parameter type
,,DYN_CALL_METH_PARAM_LITL_MOVE
Attempt to pass a constant actual parameter to a formal EXPORTING, CHANGING or RETURNING parameter
,,DYN_CALL_METH_PARAM_MISSING
An obligatory parameter was not supplied.
,,DYN_CALL_METH_PARAM_NOT_FOUND
Attempt to pass an unknown parameter
,,DYN_CALL_METH_PARAM_TAB_TYPE
Attempt to pass a parameter with an incorrect table type
,,DYN_CALL_METH_PARAM_TYPE
Attempt to pass a parameter with an incorrect type
,,DYN_CALL_METH_PARREF_INITIAL
An initial data reference was passed for an mandatory parameter.
,,DYN_CALL_METH_PRIVATE
Attempt to call a private method from outside
,,DYN_CALL_METH_PROTECTED
Attempt to call a protected method from outside
,,DYN_CALL_METH_REF_IS_INITIAL
Attempt to call a method with an initial reference
,,EXPORT_BUFFER_NO_MEMORY
The EXPORT data cluster is too large for the application buffer
,,EXPORT_DATASET_CANNOT_OPEN
The IMPORT/EXPORT statement could not open the file
,,EXPORT_DATASET_WRITE_ERROR
The EXPORT statement could not write to the file
,,GENERATE_SUBPOOL_DIR_FULL
The system cannot generate any more temporary subroutine pools
,,IMPORT_ALIGNMENT_MISMATCH
Import error: Same sequence of components, but with type conflict or different alignment in structured data types
,,IMPORT_TYPE_MISMATCH
Import error: Only with IMPORT...FROM MEMORY | FROM SHARED BUFFER...
,,MOVE_CAST_ERROR
Type conflict when assigning between object and interface references (only MOVE...?TO... or operator ?=)
,,OPEN_DATASET_NO_AUTHORITY
No authorizatino to access the file
,,OPEN_PIPE_NO_AUTHORITY
No authorization to access the file (OPEN DATASET...FILTER...).
,,PERFORM_PROGRAM_NAME_TOO_LONG
Invalid program name with PERFORM statement
,,RMC_COMMUNICATION_FAILURE
Communication error with Remote Method Call
,,RMC_INVALID_STATUS
Status error with Remote Method Call
,,RMC_SYSTEM_FAILURE
System error with Remote Method Call
,,STRING_LENGTH_NEGATIVE
Invalid access with negative length to a string
,,STRING_LENGTH_TOO_LARGE
Invalid access to a string (length too large)
,,STRING_OFFSET_NEGATIVE
Invalid access with negative offset to a string
,,STRING_OFFSET_TOO_LARGE
Invalid access to a string (offset too large)
,,STRING_OFFSET_LENGTH_TOO_LARGE
Invalid access to a string (offset + length too large)
,,TEXTENV_CODEPAGE_NOT_ALLOWED
Character set is not released in the system (SET LOCALE...)
,,TEXTENV_INVALID
Error setting the text environment (SET LOCALE...)
,,TEXTENV_KEY_INVALID
With SET LOCALE...: Value of LANGUAGE, COUNTRY or MODIFIER that is not allowed in the system.
,,TEXTENV_LANGUAGE_NOT_ALLOWED
With SET LOCALE...: Invalid value of the LANGUAGE addition.
What version of SAP are you on? If on a newer version you may be able to create your own exception class.
Regards,
Rich Heilman -
What's wrong with this simple code?
What's wrong with this simple code? Complier points out that
1. a '{' is expected at line6;
2. Statement expected at the line which PI is declared;
3. Type expected at "System.out.println("Demostrating PI");"
However, I can't figure out them. Please help. Thanks.
Here is the code:
import java.util.*;
public class DebugTwo3
// This class demonstrates some math methods
public static void main(String args[])
public static final double PI = 3.14159;
double radius = 2.00;
double area;
double roundArea;
System.out.println("Demonstrating PI");
area = PI * radius * radius;
System.out.println("area is " + area);
roundArea = Math.round(area);
System.out.println("Rounded area is " + roundArea);Change your code to this:
import java.util.*;
public class DebugTwo3
public static final double PI = 3.14159;
public static void main(String args[])
double radius = 2.00;
double area;
double roundArea;
System.out.println("Demonstrating PI");
area = PI * radius * radius;
System.out.println("area is " + area);
roundArea = Math.round(area);
System.out.println("Rounded area is " + roundArea);
Klint -
Problem with php code. Please help!
Hello!
I'm using the following syntax to bring content into my
websites' layout template:
Code:
<?php //check in the root folder first
if(file_exists('./' . $pagename . '.php'))
include './' . $pagename . '.php';
//if it wasn't found in the root folder then check in the
news folder
elseif(file_exisits('./news/' . $filename . '.php'))
include './news/' . $pagename . '.php';
// if it couldn't be found display message
else
echo $pagename . '.php could not be found in either the root
folder or the news folder!';
} ?>
What it's essentially saying is, if you can't find the .php
file in the _root folder, look for it in the /news/ folder.
It works perfectly if loading something from the _root folder
but I get an error if I need to bring something from the /news/
folder.
Can anyone see any potential problems with my code?
Thank you very much and I hope to hear from you.
Take care,
MarkI've never seen the code written like that before, but I'm
assuming it's
legal?
Perhaps try:
<?php
$newsroot = $_SERVER['DOCUMENT_ROOT']."/news";
if (!file_exists("$pagename.php")) {
elseif (!file_exists("$newsroot/$pagename.php")) {
else
Or the other thing you can try is replacing the elseif
statement with:
elseif (!file_exists("news/$pagename.php"))
If not - I'm sure Gary will be on here soon...
Shane H
[email protected]
http://www.avenuedesigners.com
=============================================
Proud GAWDS Member
http://www.gawds.org/showmember.php?memberid=1495
Delivering accessible websites to all ...
=============================================
"Spindrift" <[email protected]> wrote in
message
news:e5mled$272$[email protected]..
> Hello!
>
> I'm using the following syntax to bring content into my
websites' layout
> template:
>
> Code:
>
> <?php //check in the root folder first
> if(file_exists('./' . $pagename . '.php'))
> {
> include './' . $pagename . '.php';
> }
> //if it wasn't found in the root folder then check in
the news folder
> elseif(file_exisits('./news/' . $filename . '.php'))
> {
> include './news/' . $pagename . '.php';
> }
> // if it couldn't be found display message
> else
> {
> echo $pagename . '.php could not be found in either the
root folder or
> the
> news folder!';
> } ?>
>
> What it's essentially saying is, if you can't find the
.php file in the
> _root
> folder, look for it in the /news/ folder.
>
> It works perfectly if loading something from the _root
folder but I get an
> error if I need to bring something from the /news/
folder.
>
> Can anyone see any potential problems with my code?
>
> Thank you very much and I hope to hear from you.
>
> Take care,
>
> Mark
> -
Has anyone one else had problems redeeming the code for the free onetime download of the Star Trek 2009 Movie?
dawnfromcabot wrote:
ITUNES HAS CHARGED MY DEBIT CARD $99.99 FOR GLOBAL WAR RIOT-SOME GAME I DID NOT KNOW WAS LOADED ON MY OTHER PHONE; HOWEVER, WHEN I PULLED UP THIS APP TO SEE EXACTLY WHAT IT WAS WAS I SURPRISED TO SEE I COULD DOWNLOAD IT FOR 'FREE'. I HAVE CONTACTED ITUNES THROUGH THIS REDICULOUSLY CHICKEN SH_T SYSTEM THEY USE SO THEY DO NOT ACTUALLY HAVE TO HEAR HOW UPSET A PERSON IS NOW THAT THEY CANNOT BUY FOOD FOR THEIR CHILDREN BECAUSE OF A MISTAKE MADE ON ITUNES PART. I DID RECEIVE AN EMAILED RESPONSE FROM STEPHANIE WHO ADVISED THIS WAS PUCHARED ON A PHONE THAT HAS PURCHASED DOWNLOADS IN THE PAST. I WONDER IF SHE THOUGHT TO LOOK AT MY ENTIRE DOWNLOAD HISTORY AND DISCOVER THAT NOTHING HAS EVER BEEN PURCHASED ON MY ITUNE ACCOUNT IN THE AMOUNT REMOTELY CLOSE TO WHAT THEY ARE CHARGING ME NOW. THAT IS BECAUSE I DO TRY TO MONITOR THIS ACCOUNT AND OBVIOUSLY THIS LAST PURCHASE WAS DONE WITHOUT MY KNOWLEDGE UNTIL I CHECKED MY ONLINE BANKING ACCOUNT, WHICH I DO EVERY DAY. TO MAKE MATTERS WORSE THE APP STATES IT IS FREE TO INSTALL WHEN YOU PULL IT UP SO NO ONE HAS CLARIFIED TO MY WHERE THE $99.99 COMES INTO PLAY. I WILL NOT DROP THIS UNTIL MY BACK ACCOUNT HAS BEEN PROPERERLY CREDITED IN THE SAME TIME FRAME IT TOOK YOU TO TAKE MY MONEY. I WILL LAUNCH A COMPLAINT WITH EVERY POSSIBLE ENTITY IN THE ITUNES COMPANY AND BUSINESSES OUTSIDE THAT REGULATE THEIR BUSINESS UNTIL THIS HAS RESOLVED IN MY FAVOR AS I AM THE ONE WHO HAS BEEN VICTIMIZED BY A COMPANY I INVITED INTO MY TELEPHONE NETWORK IN GOOD FAITH!!!!!!!!!!!!
Reading that is giving me a headache, how about normal type. -
Hi all,
this is my simple code that plays a video from a specifed location.
* To change this template, choose Tools | Templates
* and open the template in the editor.
package javaapplication1;
* @author rohan
import com.sun.media.util.ContentType;
import javax.media.*;
import javax.media.Manager;
import java.io.*;
import java.net.URL;
import javax.media.bean.playerbean.MediaPlayer;
import java.awt.*;
import java.net.ProtocolException;
import javax.swing.*;
public class Main extends JFrame{
* @param args the command line arguments
public Main()
try
Manager.setHint( Manager.LIGHTWEIGHT_RENDERER, true );
Container cont=getContentPane();
cont.setLayout(new FlowLayout());
String myUrl=new String("C:\\Users\\rohan\\Softwares\\Jmf and jain sip\\Fig21_06_07\\bailey.mpg");
System.out.println("myUrl====="+myUrl);
MediaLocator myurls =new MediaLocator(myUrl);
Player myplayer=Manager.createRealizedPlayer(myurls);
System.out.println("Rohan");
Component video = myplayer.getVisualComponent();
cont.add(video);
setDefaultCloseOperation(EXIT_ON_CLOSE);
myplayer.start();
catch(Exception e)
System.out.println("Exception====="+e);
public static void main(String[] args) {
// TODO code application logic here
// JFrame fr=new JFrame("hello");
Main obj=new Main();
obj.setBounds(300, 300 , 300, 300);
obj.setVisible(true);
Problem here is i get this exception
"Exception=====javax.media.NoPlayerException: Cannot find a Player for :C:\Users\rohan\Softwares\Jmf and jain sip\Fig21_06_07\bailey.mpg
Can u plz tel me where do i make changes ,so that i can run this simple app. Plz help me...so that i can go further(plz this is my first jmf app.)
thanks.Change your file path like +"file:/C:/delta.mpg"+.
Hope this will help you to fix your issue.
Cheers,
ARIF -
Best Practice with States and lots of code lines
Hi.
This is my first application in flex.
I'm ok with as3.
Now, in as3 we were 'forced' to work mostly with external classes so hardly we have a unique code page with lots of lines.
In flex, using States leads to build codes with lots of line IF we think on states as web site pages.
I'm not sure it I understand it right. You mean: if an user visits a website built with 10 pages, but the users access only 2 pages, all that 8 remaining pages would have to be download to the swf the user loads? (this is, considering the usage os states as pages)
I'm building a system where the user logs to use it.
2 states at now: login page and home page.
I access the db, and get the user and password with this event dispatched from the db.result (this works, however i found it too-old-style looping. Is there a better way, of course, which?)
protected function usersService_resultHandler(event:ResultEvent):void
allUsers = event.result as ArrayCollection;
for (var i:uint;i<allUsers.length;i++){
if(allUsers[i].user == tx_user.text && allUsers[i].password == tx_password.text)
currentState = "home";
else
Alert.show("Fault", "Login");
While I have start to build the "home" page/state, I realized that my code would dramatcally increase. Is it the best practice? Do I have to call another url after login (to open a Session - please, some Session tutorials in flex)? Or I keep doing all in states? I'm afraid my swf would grow bigger.
ThanksOk.
The problem is that I'm not used to PHP, and I have generated the code to deal with the server automatically via Flex.
However I could add a new function, and I could guess how to catch values in the db to compare.
its a frankenstein function, but i'm afraid it also works. By now, there is no way to know whether user mistyped password or username.
public function getUserVerification($user, $pass) {
$stmt = mysqli_prepare($this->connection, "SELECT user, password FROM $this->tablename where user=? AND password=?");
$this->throwExceptionOnError();
mysqli_stmt_bind_param($stmt, 'ss', $user, $pass);
$this->throwExceptionOnError();
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
mysqli_stmt_bind_result($stmt, $row->user, $row->password);
if(mysqli_stmt_fetch($stmt)) {
return 1;
} else {
return 0;
Also I had to update the _Super_UsersService.as Class flex had generated before when I first created a php code to deal with db.
Finaly, I had to assign return and input types for the new function I've created.
Amazing... it works.
Now, when pressing the submit button on the login, flex sends user and password so php compare them instead looping it in a Array.
Also, I have made all this code inside a "loginView" component. So my main app is clean again.
I guess I understand the idea of using components and reusing them as many as possible. I just have to get used to how to access a component value from outside and vice-versa.
Now, the creationPolicy is something I would look for. This might be interesting.
Thanks a lot.
Btp~ -
Infinite loop in a catch {} statement, should be simple
Hi, I'm trying to take integer input from the console using a Java Scanner object, and I enter an infinite loop if there is an IO error inside the catch statement. Please let me know if you know what I'm doing wrong:
do
try
Problem = false; //this is a bool
start = Input.nextInt(); // Input is a Scanner, start is an Intenger
catch (Exception IOException) {
Problem = true;
System.out.println("Bad value.\n");
//The infinite loop is inside this statement.
while (Problem == true);
This code block is intended to take integer input, then, if there's an IO error, try to do it again, indefinitely, until it has successfully given Start a value. As it stands, if executed, if there is not an IO error, it works; if there is an IO error it enters an infinite loop in the catch statement. Please forgive my incompetence, any help is appreciated :)Hi, thanks for the advice to both of you, your suggestion that it is stuck seems to be correct.
I add to the catch statement:
Input = new Scanner(System.in);
To reset it, and it works now. This is probably not the best way to do things, but I'm just a student and it's for a homework assignment that does not require try / catch / for so it works for this, thank you for the help! :) -
Problem with disabled code view
Hi,
I've a problem with a template-based website which works fine
in design view but will not allow edits in code view (with the
exception of the contents of the <title> element). The
template has multiple editable regions and has been deployed on
quite a few occasions to multiple authors with varying
configurations without any trouble before, but now it is causing
quite a bit of head-scratching!
The problem originally manifested in Dreamweaver MX 2004 on
Windows 2000. An upgrade to Dreamweaver 8 has taken place and the
issue persists. Testing on a similar computer using a standard
shared drive in Windows shows the same problem in Dreamweaver 8 but
was fine in Dreamweaver MX. Working with a copied set of files on a
remote computer (Win2k and DW MX 2004) seems to somehow resolve /
circumvent the problem and the code view works fine. Unfortunately
this isn't an option for the main authors of the site who have only
their current machines available.
The fifth post down in a
thread
over at DMXzone seems to refer to a similar problem, but the
workaround highlighted there has not worked for me.
I'm not really a heavy Dreamweaver user but I can normally
figure things out. This one however has got me stumped - anybody
got any ideas? (Apologies if it's a really simple setting or flag
that I should know about, but I've not been able to find anything!)
Cheers,
DanCa you post a link to the page, please?
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com
- Template Triage!
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
http://www.macromedia.com/support/search/
- Macromedia (MM) Technotes
==================
"yorkdan" <[email protected]> wrote in
message
news:[email protected]...
> Hi,
>
> I've a problem with a template-based website which works
fine in design
> view
> but will not allow edits in code view (with the
exception of the contents
> of
> the <title> element). The template has multiple
editable regions and has
> been
> deployed on quite a few occasions to multiple authors
with varying
> configurations without any trouble before, but now it is
causing quite a
> bit of
> head-scratching!
>
> The problem originally manifested in Dreamweaver MX 2004
on Windows 2000.
> An
> upgrade to Dreamweaver 8 has taken place and the issue
persists. Testing
> on a
> similar computer using a standard shared drive in
Windows shows the same
> problem in Dreamweaver 8 but was fine in Dreamweaver MX.
Working with a
> copied
> set of files on a remote computer (Win2k and DW MX 2004)
seems to somehow
> resolve / circumvent the problem and the code view works
fine.
> Unfortunately
> this isn't an option for the main authors of the site
who have only their
> current machines available.
>
> The fifth post down in a
>
http://www.dmxzone.com/forum/topic.asp?topic_id=33748
> seems to refer to a similar problem, but the workaround
highlighted there
> has
> not worked for me.
>
> I'm not really a heavy Dreamweaver user but I can
normally figure things
> out.
> This one however has got me stumped - anybody got any
ideas? (Apologies if
> it's
> a really simple setting or flag that I should know
about, but I've not
> been
> able to find anything!)
>
> Cheers,
> Dan
>
>
> -
Problem with character code NCR (example : cộng h�a x� hội)
Dear
I have problem with character code NCR when display this string "cộng h�a x� hội" on web page using JSF. I print out like this c & # 7897 ; ng h � a x � h & # 7897 ; i
Thanks for helpjverd wrote:
A better approach would be to take a char rather than a String in that method, since it's a better model for what you're converting. A char would also let you use switch statement.I was going to say this as well but you beat me to it.
@OP, you really should use char for this. You're unnecessarily taking each char, converting it to a string, and working with the single-character string. That's not very efficient. -
Can i add an if statement anywhere in this code?
I need to add an if statement anywhere in this code, it doesnt matter where, but if it is nested it would be better. any ideas?
import java.text.DecimalFormat;
import javax.swing.JOptionPane;
import javax.swing.*;
import java.util.*;
import static java.lang.System.out;
import java.util.Scanner;
//Defines the counter for the student count and the lists for students
//to be saved in
public class EdronProject {
private int studentCount;
private static final String USAGE = "Usage: java EdronProject <student count>";
private List<Student> list;
//Set up the counter fo the number of students and the list in which
//each student's information is saved once processed
public EdronProject(int count) {
studentCount = count;
list = new ArrayList<Student>();
//Checks the number or arguments, and it executes the rest of the code
//if there is 1 argument or more (the number of arguments = the number
//of students being processed)
public static void main( String args[] ) throws NumberFormatException {
int count = 0;
switch (args.length) {
case 1: count = Integer.parseInt(args[0]); break;
default: System.out.println(USAGE);
//Defines method for processing and printing students within the
//EdronProject class
EdronProject edp = new EdronProject(count);
edp.processStudents();
edp.printStudents();
class Student {
//Define integer values for the 5 subject's grades, the gradeCounter (used
//in the processing stage) and the student name string
private int
gradeCounter,
grade1,
grade2,
grade3,
grade4,
grade5;
private double total;
private String studentName;
//Use setter getter methods for the student name to be retrieved
public void setStudentName(String name) {
studentName = name;
public String getStudentName() {
return( studentName );
//Use setter getter methods for the grades inputted to be retrieved
//by the processing stage
public void setGrade(int gradeNo, int grade) throws IllegalArgumentException {
switch( gradeNo) {
case 1 : grade1 = grade; break;
case 2 : grade2 = grade; break;
case 3 : grade3 = grade; break;
case 4 : grade4 = grade; break;
case 5 : grade5 = grade; break;
default: throw new IllegalArgumentException("ERROR: Bad grade number passed!");
//Increase grade counter for it to register the number of grades inputted
//by user
gradeCounter++;
public int getGrade(int gradeNo) throws IllegalArgumentException {
int grade = 0;
switch( gradeNo) {
case 1 : grade = grade1; break;
case 2 : grade = grade2; break;
case 3 : grade = grade3; break;
case 4 : grade = grade4; break;
case 5 : grade = grade5; break;
default: throw new IllegalArgumentException("ERROR: Bad grade number passed!");
//Return grade values for them to be used by the processing stage
return( grade );
//Calculate the total by adding al 5 grade values
public double getTotal() {
total = (getGrade(1) + getGrade(2) + getGrade(3) + getGrade(4) + getGrade(5));
//Total value returned for it to be used to calculate the average
return total;
//Average is calculated by dividing the total over the grade
//counter (number of grades inputted)
public double getAverage() {
return ( (gradeCounter == 0) ? 0 : total / gradeCounter);//Get input from user for student's 5 grades which are set as Grade 1, 2, 3, 4, 5
//and each five inputs for the student are saved to their own list along with the
//student name
public void processStudents() {
for (int counter = 0; counter < studentCount; counter++) {
Student student = new Student();
student.setStudentName(JOptionPane.showInputDialog("Enter student's name:"));
student.setGrade(1, Integer.parseInt(JOptionPane.showInputDialog( "Enter the student's grade for Psychology \n(You may ONLY use whole positive numbers ranging from 0 to 10)")));
student.setGrade(2, Integer.parseInt(JOptionPane.showInputDialog( "Enter the student's grade for Math \n(You may ONLY use whole positive numbers ranging from 0 to 10)")));
student.setGrade(3, Integer.parseInt(JOptionPane.showInputDialog( "Enter the student's grade for Art \n(You may ONLY use whole positive numbers ranging from 0 to 10)")));
student.setGrade(4, Integer.parseInt(JOptionPane.showInputDialog( "Enter the student's grade for Science \n(You may ONLY use whole positive numbers ranging from 0 to 10) ")));
student.setGrade(5, Integer.parseInt(JOptionPane.showInputDialog( "Enter the student's grade for English \n(You may ONLY use whole positive numbers ranging from 0 to 10)")));
list.add(student);
//Begin printting stage for each student entered
public void printStudents() {
for ( int i = 0; i < list.size(); i++ ) {
Student s = list.get(i);
printStudent(s);
//Print the student name along with each grade entered separated by commas
//and the total and average values in separate lines
private void printStudent(Student student) {
System.out.println("Student Name: "+student.getStudentName()
+", Pych: "+student.getGrade(1)
+", Math: "+student.getGrade(2)
+", Art : "+student.getGrade(3)
+", Sci : "+student.getGrade(4)
+", Eng : "+student.getGrade(5)
+",\n Total : "+student.getTotal()
+",\n Average: "+student.getAverage()+"\n");
-
How to consolidate the financial statements for 3 company codes, assigned t
Hi Friends,
How to consolidate the financial statements for 3 company codes, assigned to 3 different companies, 3 different fiscal years, 3 different controlling areas and all the 3 Company Codes assigned to same chart of accounts in the same client?
Can we need any ABAP program for this (or) Is it possible using Report Painter?
Please help me.
ThanksHi friend,
Is it a real-time situation or something you are visualising ?
For consolidation, you can use a group chart of accounts and select that in the operative chart of accounts for consolidation purposes. This would work provided the company codes use the same operative chart of accounts and fiscal year.
I hope the above would be helpful to you.
Regards,
Maybe you are looking for
-
I can no longer get email on my account
I can log-in to Apple but when I try to get email the system tells me my password is incorrect ... I've tried to change my password but nothing helps ... please help!!!
-
When I try to open my iTunes, that is the message I get. Is there any way to fix this without uninstalling my iTunes and reinstalling it?
-
We want vendors to deliver their materials on a fixed day during the week (for example always on Wednesday). The MRP run should schedule the req's backwards to the first delivery day that meets to our needs. Can anyone tell me if this is standard SAP
-
Jdev 10g and 9iAS 9.0.3
Hi, Could someone help me out with the following: A J2EE Application built with JDEv 10g doesn't work on OC4J 9.0.3 None of the CMP EJB can be instantiated even if the entity does exist in the database -- FindByPrimaryKey returns 'no such entity' It
-
I got problems using oc4j basic security, anybody can help me?
hi guys i was trying the Orion security Primer (site www.jollem.com) i'm quite sure to have done all the "Setting up access restrictions"correctly here is the principals.xml (included in the addressbook.ear META-INF) , the orion-application.xml file