Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Java application

Have Programming Question? Ask it here!
 
 
 


soomei
Java application
1 Answer(s)      a year and 11 months ago
Posted in : Java Beginners


public int remainder(int a, int b)
    {
        int answer = a % b;
        System.out.printf("%d % %d = ", a , b);
        return (answer);    
    }

and in my main, 

int answerRemain = calc.remainder (3,4);
        System.out.println (answerRemain);

and when i tried running it, it tells me:-
Exception in thread "main" java.util.IllegalFormatFlagsException: Flags = ' '
    at java.util.Formatter$FormatSpecifier.checkText(Formatter.java:2945)
    at java.util.Formatter$FormatSpecifier.<init>(Formatter.java:2647)
    at java.util.Formatter.parse(Formatter.java:2480)
    at java.util.Formatter.format(Formatter.java:2414)
    at java.io.PrintStream.format(PrintStream.java:920)
    at java.io.PrintStream.printf(PrintStream.java:821)

if i take out the % from "%d % %d = ", so that it is "%d %d" then it runs fine and gives the correct answer. my question is why wont it compile and, how can i print out the modulus sign so my output looks like 3 % 4 = 3. thank you!


Advertisement
View Answers

September 19, 2012 at 5:04 PM


We have modified your code. The character you want to display in the printf method is actually invalid.Therefore error occurs. Anyways, check your code.

class  FindRemainder
{
    public int remainder(int a, int b) { 
        int answer = a % b;
        System.out.println(a+" % "+b+" = " +answer);
        return (answer);
}
    public static void main(String[] args) 
    {
        FindRemainder f=new FindRemainder();
        f.remainder(3,4);
    }
}


Related Tutorials/Questions & Answers:
Java Application
Java Application  Hi, What is the applications of Java in development of software? What type of applications can be developed using Java programming Language? Can anyone tell me the url for downloading sample projects in Java
Java Client Application example
Java Client Application example  Java Client Application example
Advertisements
Java Client Application
Java Client Application  Java Client Application
Java application - Java Beginners
Java application  Write a Java GUI application called Index.java that inputs several lines of text and a search character and uses String method indexOf to determine the number of occurrences of the character in the text
Java HTML Client Application
Java HTML Client Application  Java HTML Client Application
Batch file for java application
Batch file for java application  please tell me how to create the batch file for java application(using swings).the application is created with netbeans
JAVA APPLICATION - Java Beginners
JAVA APPLICATION   Hi, I have this question and I'm stuck. Please guide me? Thanks. Write a Java application to implement the program logic... with e : " + strAr[i]); } } } } For more information on Java visit
java reminder Application
java reminder Application  Create an awt application which imitates a reminder application,that stores notes and specify date and time to be reminded
java reminder Application
java reminder Application  Create an awt application which imitates a reminder application,that stores notes and specify date and time to be reminded
java Application to java Applet
java Application to java Applet  sorry Java master disturb again how can i modify below this Java application to applet because in swtich case i had put this countinue selection source code to make user choosing so hope can
Write a java application program........?
Write a java application program........?  Welcome every One : I have Q in Java? Q : Write a java application program that reads 20 integer numbers input by the user and prints how many numbers > 100 and how many numbers
java application - Framework
java application   Hi How to make .exe or a plateform independent executable file( i think its jar in case of java) of a java code. Thnx
Fax service in Java application.
Fax service in Java application.  Hello, I want to develop a Java application to send fax to any destination fax numbers. Anyone who knows about this, please tell how I can do this. Is there any free libraries
Java application - Java Beginners
Java application  Dear sir, I Designed a Window Throung Swing component Using JDBC. My Problem is that How and What component may used... the following link: http://www.roseindia.net/java/example/java/swing/Print.shtml Hope
chat application - Java Beginners
chat application  i hv created a chat application , but i hav facing problem when i run it in lan , pc ping but apllication doent giv ressponce plz help for these if some one have work on java chat application my email id
Java application PLZ ?
Java application PLZ ?  Write an application that demonstrates each of the following methods, based on the statement String dedicate = ?Dedicated to making your event a most memorable one:; indexOf(?D?) charAt(15) endsWith(one
Drools Application in Java
Drools Application in Java  when I have make a drools application using java and eclipse i have a facing a error Unable to instantiate service for Class 'org.drools.builder.KnowledgeBuilderFactoryService' I was searching
Distributed application and java
Distributed application and java  Hi, Am about to develop a Java swing application. This software will be used by 20 branch offices and every... like to go forward with the Java swing application only for this. And the way
Java web Application
Java web Application  Hi! I have developed a java web application project using netbean IDE with glassfish server. My question is how to create a runnable file from this. How can we make it to a single file? I think it is war
Fingeprint matching in java application
Fingeprint matching in java application  I am developing a java application which require fingerprint identification and verification. It is a webservice application. following considration we have to take in to mind. 1. if I am
Problem in uploading java application
Problem in uploading java application  I have uploaded my java application (folder created under webapps) using Filezilla FtpClient.Application... application it is showing javax.servlet.ServletException: Parse Error in JSP page
Java application Help?
Java application Help?  Write an application that accepts a users password from the keyboard. When the entered password is less then six characters more then 10 characters, or does not contain at lease one letter and one digit
Constructing Application of Java
Constructing Application of Java   Hi,I am doing project on java as front end and database as back end.I completed it almost on my computer but now I want to distribute it to some other computer.so have to convert the java source
java web application - Ant
java web application  hai, iam new to J2EE. i've installed jdk... tell me the steps to build and deploy a small web application on MyEclipse?(like HelloWorld).Please tell me the directory structure to place my java classes
Java application that uses the classes and
Java application that uses the classes and   i have this class diagram with three classes: Curriculum, Course, and Lecture. Your class diagram...) I wish Write a Java application that uses the classes and methods above
Java application - JDBC
Java application  Seasons greetings, I successfully designed the Food festival application using the help rosenet team rendered but it is not exactly the specification i said.so i altered it.I thank rosenet team for their timely
Java application help!
Java application help!  In Deep Water Associates operates a business... (based on the fill-up time) for a pool. Write an application that prompts the user...-up price. Save the application as Swimming.java. Parameter Fee for cleaning Pool
Java application Help?
Java application Help?  Write an application that can hold five doubles in an array. Display the doubles from first to last, and then display the doubles from last to first. Save the file as DblArray.java. Use the logic
online test application in java
Online Test Application Table Of Contents Introduction To Application Database Design Creating Data Access Object (DAO) Design Pattern Creating Views Writing Actions Mapping Application Admin Module User Module Download
Java Spring Desktop application
Java Spring Desktop application  Hi i am developing a desktop java spring application..It has many Jframes forms and classes...How to close one Jframe from another..Please tell... First jframe package desktopapplication2
java spring simple application
java spring simple application  hai I have design a simple application in this I always found class not found exception. I am sendig code as follows please resolve this and send me.my directory structure is as follows Project
deploy java application
deploy java application  how i will deploy an java applet in Apache Http Server in unix
java chat application
java chat application  Can u plz send me java code for Lan communicatino(chat
java chat application
java chat application  Can u plz send me java code for Lan communicatino(chat
java application - Applet
java application  codes in repetition and decision  codes in repition and decision
java application - JDBC
java application  Hi team rosenet, I ve used the ideas you gave and created an application.I need to do a modification to this code... main(String[] args) { // TODO code application logic here
deploy application - Java Beginners
deploy application  i want to deploy to tom cat server a web application using a eclips IDE. i already start the server but haven't no idea how to create the the war file using eclips. i pleasure if any one can help me. alsp
java application/applet - Java Beginners
java application/applet  In this project, the student has to develop and submit a program for a Java application / applet which contains a set of GUI components as detailed below. 1. The Java applet page/application models
online test application in java
online test application in java  Can questions come in html file... radiobuttons in our application, you can take textarea, textfield etc. Here we have created... the following link: http://www.roseindia.net/jsp/online-quiz-application-jsp.shtml
Java Bouncing Application
Java Bouncing Application  Hi I'm using Eclipse ide to add more implementation to this simple bouncing program. I'm having trouble implementing the following: -adding functionality of buttons and having color chooser -able
Java swimming application
Java swimming application  In deep water associates operate a business that offers a variety of services to customers who own swimming pools, including cleaning and filling pools. Create pool class that calculates the price
convert java Application to Java Applet
convert java Application to Java Applet  hi every Java Master or Java Professional , my Name Is Vincent i'm java beginner can i ask a question regarding for Java application convert to Java Applet. below her is my sample
convert java Application to Java Applet
convert java Application to Java Applet  hi every Java Master or Java Professional , my Name Is Vincent i'm java beginner can i ask a question regarding for Java application convert to Java Applet. below her is my sample
Java Application change to java applet
Java Application change to java applet   Hi every Java Masters i'm Java beginner ,and i want below this figures source code convert to Java Applet hope every Masters can helping thank . import java.util.*; import java.text.
java Application Convert to java Applet
java Application Convert to java Applet  Hi every Java Masters i'm Java beginner ,and i want below this figures source code convert to Java Applet hope every Masters can helping thank . import java.util.*; import java.text.
current application cursor - Java Beginners
current application cursor  Hi all, I want to design one tool for that i need to find out the application in which is running among other application.(if currently three application is running means i want to find out
run a java application - Java Beginners
run a java application  Hai Deepak, I ve set my environment...; CLASSPATH= C:\Program Files\Apache Tomcat 4.0\common\lib\servlet.jar; JAVA_HOME=C:\Program Files\Java; path=C:\Program Files\Java\jdk1.6.0_06\bin; My
Simple IO Application - Java Beginners
Simple IO Application  Hi, please help me Write a simple Java application that prompts the user for their first name and then their last name. The application should then respond with 'Hello first & last name, what
Web application? - Java Interview Questions
Web application?  What is webapplication?  Hi friend, Any application that uses Web Technologies including web browsers, web servers and Internet protocols is called Web Application. A web application can
Sms to mobile using java application
Sms to mobile using java application  Hi, i want to send sms to mobile using java application. But i dont have any idea for this procees. So kindly suggest me any ideas. regards vijayalakshmi
Advertisements
 

 

 

DMCA.com