Output Of A Staircase?
Jan 9, 2014
New to programming, see my code
import java.util.Scanner;
class LeftBottomTriangleNew2
{
public static void main(String[] args)
[Code]....
the staircase looks good,however I want to remove the last line and if user chooses 9 i want them to get message "enter number from 1 to 8" and do not print out the staircase.
View Replies
ADVERTISEMENT
Feb 15, 2015
my output fails to display me the 2nd output.Here's my code.
import java.util.Scanner;
public class year
{
public static void main (String [] args)
{
Scanner console = new Scanner (System.in);
System.out.print("Enter the choice of book(A-ABC,D-EFG):");
String x = console.next();
System.out.print("Enter the rate (1-3):");
int y= console.nextInt();
System.out.print("Enter number of kids reading:");
int k = console.nextInt();
[code]....
When I key '0" for kids, it did not appear the second print out. I don't want the first print out to be the output.
View Replies
View Related
Apr 2, 2014
I have been working through a problem, and I have working what I need to work. However, it prints out to the command line and I want to output to a GUI. I have set up the GUI and everything seems fine there, the problem is when I try to change the output that was coming through the command prompt to a JTextField. I am getting the following error.
The field DataAnalyzerGUI.dataOutput is not visible
Java Code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class DataAnalyzerGUI extends JFrame {
private JPanel contentPanel;
private JButton btnExit;
private JButton btnClose;
private JButton btnFBdata;
[code]....
View Replies
View Related
Aug 30, 2014
I need this to print output opposite the way it is. When it reads my file it prints it out like this:
4X^0+3X^1+-2X^2+5X^3+6X^5
But is needs to be this:
6x^5+5x^3+-2x^2+3x^1+4x^0
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Iterator;
import java.util.Set;
[code]....
View Replies
View Related
Mar 1, 2014
Any way i can format this output into columns?
for(int i = 0; i < 5; i++) {
System.out.println(t[i]+n[i]+s[i]);
}
View Replies
View Related
Jan 14, 2015
I am writing this program for my Java level 1 class. I am able to get it to compile and run, however nothing is outputted. Below are the instructions and the code that I have written.
Instructions:
Write an application that calculates and displays the amount of money a user would have if his or her money could be invested at 5 percent interest for one year. Create a method that prompts the user for the starting value of the investment and returns it to the calling program. Call a separate method to do the calculation, and return the result to be displayed.
Below is the code that I have written
import java.util.Scanner;
public class Interest
{
//main method
public static void main(String[] args)
{
originalAmount();
Scanner input = new Scanner(System.in);
[code]....
View Replies
View Related
May 8, 2014
I am a beginner in Java and had started writing a program to read text from a file and want to output each row to JTextField.
I want to compare each row of number so I need a field where each row of data keeps refreshing.
I can do it with Visual Basic with loop, Me.refresh, and system.thread.sleep. But I need to achieve it with Java.
I use System.out.println(num); which showed all rows of the file.
When I use textArea.append(num + ""); to output it, I only got all rows displayed after it reached the end. (textArea = new JTextArea("",10,30);
If I use dataRead.setText(num); to output it, I only got the last row displayed after it reached the end. dataRead = new JTextField(7);
View Replies
View Related
Feb 12, 2015
i need to take a txt file and turn it into a csv(comma seperated value) output on console but where to begin.
View Replies
View Related
Feb 17, 2015
You are given a file containing the names and addresses of company employees from many years ago that your manager has asked you to import into a database. You can use a CSV file and your database application to load the file, but the file your manager gave you was exported from an old, non-standard accounting system. Here is its format:
Fred|Flintstone
1212|Bedrock
Austin|Texas
Harry|Potter
1234|Hogwarts Road
[Code] .....
View Replies
View Related
Feb 15, 2015
I'm not sure why, but my program does not produce an output. It is supposed to output total charges.
/*This program provides the user with the price of their monthly internet service based on two inputs.The program asks users which subscription they have. The options are A, B, or C. This is the first input.
The program then will ask the user how many hours they used the internet for. This is the second input.Then, based on the package number, the program will compute their monthly bill. This is the output.
The program calculates the price based on the following prices:
Package A: For $9.95 per month, 10 hours of access are provided. Additional hours are $2.00 per hour.
Package B: For $13.95 per month, 20 hours of access are provided. Additional hours are $1.00 per hour.
Package C: For $19.95 per month, access is unlimited.*/
import java.util.Scanner;
public class Lab03SV
[code]...
View Replies
View Related
May 17, 2015
I am learning while loops but the output I am getting is not what I want? My class:
public class BottlesOnWall {
public static void main (String[] args) {
int x = 99;
while (x > 1) {
System.out.println(x + " bottles on the wall!");
[Code] .....
The output I am getting is this:
99 bottles on the wall!
98 bottles on the wall!
97 bottles on the wall!
96 bottles on the wall!
95 bottles on the wall!
[Code] ....
I want it to stop on "2 bottles on the wall!" and then print "Only 1 bottle left on the wall!". How do I go about doing that? I have tried different variations of the condition (x>1), I have tried (x>5) but it still goes down to 1 bottle?
View Replies
View Related
Feb 1, 2015
It has been about 2 years that I'm programming in JAVA and never has this occurred to me about the reason why this happens. So, in this code snippet
public class Test {
public static void main(String[] args) {
char m = 'A';
int p = 15;
System.out.println(m+p);
System.out.println("Answer :"+m+p);
}
}
The statement "System.out.println(m+p);" returns "80" which is evident that the type of the entire expression is promoted to the value of the largest data type int. But in the statement " System.out.println("Answer :"+m+p);, why does the output change to "Answer :A15" but not "Answer :80"?
View Replies
View Related
Feb 28, 2015
I need to display my calculations in a table format using loops.
//Imports
import java.util.*;
import java.text.*;
public class YourLoanCalculator {
[code]....
The increments are correct, but I wanted them listed under the "Payment #:" column. I figure that if I do that, I can also correctly display the interest, principal, unpaid balance and total interest paid at that point, right?
View Replies
View Related
Oct 17, 2011
I would like to enter a new item into a CSV file but all my items being entered are all staying on one line in the CSV file. I would like each new item to show up on a new line and I can't seem to find the code to make it work.
public String addItem(String newItem, int credits, String code)
{
String money = Integer.toString(credits);
try {
BufferedReader itemsCSV =
new BufferedReader(new FileReader("itemList.csv"));
[code]....
View Replies
View Related
Mar 10, 2014
I have a for cycle in which I have a line for printing in the output file. But the file remains empty.
I inserted ShowMessageDialog in the same cycle in order to see what are the results of the calculations that are supposed to appear in the output file, and I see that the results are fine.
Here is some of the code:
XML Code: BufferedWriter bwLink = new BufferedWriter(new FileWriter("." + ToolKit.fileSeparator() + OUTPUT_FILE_LINK));
bwLink.close();
....
....
...
PrintWriter outLink = new PrintWriter(new BufferedWriter(
new FileWriter("." + ToolKit.fileSeparator() + OUTPUT_FILE_LINK, true)));
...
...
JOptionPane.showMessageDialog(GuiMain.this, " Link: " +counter + " Normal: " + trafficResult[0] + " ;
[code]....
View Replies
View Related
Jul 7, 2014
[URL] I am unable to get any XML output. I am unable to figure out how to send the contents of System.out to a String that can be printed. I saw an SO post and tried using ByteOutputStreamArray, but that did not work.
XML Schema -
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb" jxb:version="2.0">
<xsd:element name="Greetings" type="GreetingListType" />
<xsd:complexType name="GreetingListType">
<xsd:sequence>
[code]....
View Replies
View Related
Feb 13, 2015
How can I extract data from two different files but produce one output. For example, the first three columns are from text_file_1 and the last column (the last foruth column of the output) is from text_file_2...
View Replies
View Related
Apr 21, 2015
I am working on a program that accept input file from user and then from the input file, it count the occurrence for each words then put those result into the output. However, after I run this program, nothing shows up in the output file. It is totally empty...It seems nothing wrong with my code... Here is my code
import java.util.*;
import java.io.*;
public class occurance {
public static void main(String[] args){
String inputFileName="";
String outputFileName="";
if(args.length == 0){
[code]....
View Replies
View Related
Jan 13, 2014
I have one code [taking from on line SCJP exam preparation site]. I have 2 question in my mind:
1) addValue() is non static method then why it is running without object inside constructor. By this rule it should show compilation error.
2) With ref variable of parent always non overridden methods of parent run then it must value of 10 [If i forgot 1st point ]
But it is giving 40. Code is as below:
class Base{
int value = 0;
Base(){
addValue();
}
void addValue(){
value += 10;
[Code] .....
View Replies
View Related
Feb 18, 2014
I have an output file which should contain some total values from calculations, but at the end it is empty.Here is my code in the try catch block:
BufferedWriter bwArea = new BufferedWriter(new FileWriter("." + ToolKit.fileSeparator() + OUTPUT_FILE_AREA));
bwArea.close();
in the method after that I have:
PrintWriter outArea = new PrintWriter(new BufferedWriter(
new FileWriter("." + ToolKit.fileSeparator() + OUTPUT_FILE_AREA, true)));
Integer total=traffic[0]+traffic[1]+traffic[2]+traffic[3];
double greenPercent = ((double)(traffic[0] )) / total*100;
double yellowPercent = ((double)(traffic[1]))/total*100;
double redPercent = ((double)traffic[2])/total*100;
double blackPercent = ((double)traffic[3])/total*100;
[code]...
View Replies
View Related
Jan 11, 2015
I am trying to output the content of a JTable to printer.Heres my code:
Java Code: private void cmdPrintActionPerformed(java.awt.event.ActionEvent evt) {
try
{
PrintRequestAttributeSet set = new HashPrintRequestAttributeSet();
set.add(OrientationRequested.LANDSCAPE);
vendTransOpen.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
vendTransOpen.setModel(new Classes.VendTransOpenGrid());
vendTransOpen.setSize(vendTransOpen.getColumnModel().getTotalColumnWidth(), vendTransOpen.getRowHeight() *
[code]....
I have a problem with the table and column size. I would like it to be the same size as I have on my screen.
View Replies
View Related
Mar 2, 2014
Is it possible to use Java to input data to website, and then get the output? For example, can you use java to input a word to dictionary.com and then get the data from the resulting webpage? I've noticed there are sometimes android applications where users of a website create an app version of the website, so presumably they are working on a similar principal of using java (for android applications) to inputting information (such as when you log into the website through the app) etc. and getting the same output information you would get if you inputted that information into the actual website itself.
The real problem is:
I'm not sure if I'm correct in assuming that this is all just java doing this or if there is some other programming language being implemented to achieve this resultI don't know what terminology I should be using, as I'm not getting any results when I search on the web for how to do this.
View Replies
View Related
Aug 8, 2014
My code is already running. But the problem is, i don't want to see 0 denomination. like for example if i input 3.86 in (dollars).
dollars: 3
quarters: 3
dimes: 1
pennies: 1
so my problem is. it still showing 0 denomination like this:
dollars: 3
quarters: 3
dimes: 1
nickels: 0
pennies: 1
Currently using latest netbeans and if im correct we are using methods and class runner?.. Anyways here's the code..
for method:
package MyPrograms;
public class Mp3Method {
public int dollars(int dollars,int remainingAmount){
return dollars = remainingAmount / 100;
}
public int quarters(int quarters, int remainingAmount){
return quarters = remainingAmount / 25;
[Code] .....
View Replies
View Related
Apr 3, 2015
I am writing a code that requires a user to input a number, then output the individual digits and then add the sum of the digits. I have the entire program written, but I cannot figure out how to make zeros output as individual digits. If I input 400, it only shows 4 and not 4 0 0. Here is the code:
import java.util.*;
public class week4program {
public static void main(String[] args) {
[Code].....
View Replies
View Related
Nov 3, 2014
I'm having trouble with this program:
//********************************************************************
// Demonstrates the existence of separate data space in multiple instantiations of a programmer-defined class.
//********************************************************************
[code]....
Basically i'm trying to add one more "coin" to flip. My problem is that my if-else structure isn't working correctly here's what it looks like:
if (count1 < GOAL)
if (count2 < GOAL)
System.out.println("Coin 3 Wins!");
[Code] .....
It only works correctly when "coin2" wins.How would I modify my if else structure to get the output I am looking for?
View Replies
View Related
Jun 29, 2014
How would I display certain output text if the text entered equaled "text".
So lets say you enter a question into a JTextField. You press a button that submits the text. The output displayed depends on what the question you asked was.
Think about it as "If question = What color is the sky? On submit, display text "Blue". How to implement this.
View Replies
View Related