I need to write a Java program using Visual Studio 2010 that allows a user to in
ID: 3637051 • Letter: I
Question
I need to write a Java program using Visual Studio 2010 that allows a user to input a word , then the program calculates the value of the inputted word based on the rule:
A=1 cent, B=2 cents, C=3 cents.....Z=26 cents.
The goal is to find words that equal exactly 100
based on the rule:
A=1 cent, B=2 cents, C=3 cents.....Z=26 cents
I have created a form that has a textbox for the inputted word by the user, a calculate button, a clear button, a exit button, and a label to display the inputted word by the user and the value of the word, another label displaying : This Word Is Equal to One Hundred!
My partially completed code is as follows:
[code]
Public Class MainForm
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub exitButton_Click(sender As Object, e As System.EventArgs) Handles exitButton.Click
Me.Close()
End Sub
Private Sub calcButton_Click(sender As Object, e As System.EventArgs) Handles calcButton.Click
' calculate and display the word
' declare variables
Dim inputWord As String
Dim calculatedInputWord As String
Dim char as
' assign user input to variables
inputWord =
calculatedInputWord =
' performs calculations
' calculate and display the inputted word
calculatedWordLabel.Text = Convert.ToString
End Sub
Private Sub clearButton_Click(sender As Object, e As System.EventArgs) Handles clearButton.Click
' prepares the screen for the next word
TextBox1.Text = String.Empty
calculatedWordLabel.Text = String.Empty
TextBox1.Focus()
End Sub
End Class
[/code]
Explanation / Answer
import java.io.*; public class WriteTextFileExample{ public static void main(String[] args)throws IOException{ Writer output = null; String text = "Rajesh Kumar"; File file = new File("write.txt"); output = new BufferedWriter(new FileWriter(file)); output.write(text); output.close(); System.out.println("Your file has been written"); } }