Будьте нежны, это мой первый раз.:)
Вот ущерб: я нахожусь в неосновном классе программирования, в котором я до сих пор преуспел.Но тогда был этот монстр.Этот проект - простая банковская программа, но у меня были некоторые проблемы с тем, что он зацикливается навсегда или символы не известны.
Вот мой код;если это выглядит странно или, возможно, сделано неэффективно, то это потому, что именно туда меня привел класс.К вашему сведению, следующий урок посвящен массивам (не знаю).
import java.text.*;
import java.util.*;
/**
* Bank program
*
* @********
* @3
*/
public class Proj3also
{
public static void main(String []args)
{
DecimalFormat df = new DecimalFormat("#0.00");
System.out.println("Welcome to the banking program.");
System.out.println("");
Scanner s = new Scanner(System.in);
System.out.print("Please enter your starting balance: ");
double bal = Double.parseDouble(s.nextLine());
System.out.print("");
double deposit;
double withdraw;
do
{ System.out.print("Enter (d)eposit, (w)ithdraw, (b)alance check, or (q)uit: ");
if (input == 'b' || input == 'B')
{
System.out.print("Your balance is: $");
System.out.println(df.format(bal));
System.out.println("");
}
else if (input == 'd' || input == 'D')
{
System.out.print("Enter the amount to deposit: ");
deposit = Double.parseDouble(s.nextLine());
bal = bal + deposit;
System.out.println("");
}
else if (input == 'q' || input == 'Q')
{
System.out.print("");
System.out.print("Exiting the banking program. Goodbye!");
}
else if (input == 'w' || input == 'W')
{
System.out.print("Enter the amount to withdraw: ");
withdraw = Double.parseDouble(s.nextLine());
if (withdraw > bal)
{
System.out.println("Transaction failed. Withdraw amount cannot exceed balance.");
System.out.println("");
}
else
{
bal = bal - withdraw;
System.out.println("");
}
}
}
while(input != 'q' || input != 'Q');
}
}
Вот как выглядит программа инструктора:
http://i15.photobucket.com/albums/a376/decode_6/project3.png
Любая помощь будет принята с благодарностью!