Ok,
I have a CS assignment due tomorrow and I am missing one of the requirements for the project.
I have to write a program that asks a student for a list of information and then generates a report.
It should display something like this:
image.jpg
So, I finished writing the code. But, I was not able to align the text properly.
Here's a part of my code that I want to align (the whole thing is huge):
System.out.print (subj1 + "\t"); //Subject 1 System.out.printf ("%03d",gradesubj1); // Mark for Subject 1 System.out.println (subj2 + "\t" + gradesubj2 + "%"); // Subject and Mark for Subject 2 System.out.println (subj3 + "\t" + gradesubj3 + "%"); // Subject and Mark for Subject 3 System.out.println (subj4 + "\t" + gradesubj4 + "%"); // Subject and Mark for Subject 4 System.out.println ("\nAverage : " + gradeavg + "%"); // Grades Average System.out.println ("\nTotal money earned : $" + workmoneytotal); System.out.println ("Number of affordable tutoring hours: " + tutoringhours_int + " hours");
As you can see, I tried to align with System.out.printf ("%03d"....);
The program compiles correctly. But when I run it, I get this:
(part of the output)
java.util.IllegalFormatConversionException: d != java.lang.Double at java.util.Formatter$FormatSpecifier.failConversion(Unknown Source) at java.util.Formatter$FormatSpecifier.printInteger(Unknown Source) at java.util.Formatter$FormatSpecifier.print(Unknown Source) at java.util.Formatter.format(Unknown Source) at java.io.PrintStream.format(Unknown Source) at java.io.PrintStream.printf(Unknown Source) at Budget.main(Budget.java:114) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at edu.rice.cs.drjava.model.compiler.JavacCompiler.runCommand(JavacCompiler.java:271)
What's wrong?
Thanks in advance