• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

Tuition fee balance calculator

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tuition Program
Enter tuition: 20000.45
Mode of payment
[1] Full Payment - 20% Discount
[2] Installment A - 5% Interest
[3] Installment B - 10% Interest
Enter the mode of payment: 1
You are going to pay P16,000.36 tuition.

---------------------------------------------------------
Tuition Program
Enter tuition: 4999
Tuition that is less than 5,000 is not allowed.

----------------------------------------------------------
Tuition Program
Enter tuition: 20000
Mode of payment
[1] Full Payment - 20% Discount
[2] Installment A - 5% Interest
[3] Installment B - 10% Interest
Enter mode of payment: 4
Invalid mode of payment. Select from 1 - 3 only.

Does anyone knows how to program this output.
 
Bartender
Posts: 7804
70
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What step are you stuck on? Can you write a method that implements the menu selection?
 
Christian Gray
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can I code this input that when I enter a 4999 the program will say "Tuition that is less than 5,000 is not allowed? and if I 4 in the mode of payment it will shows " invalid mode of payment".
Mode of payment
[1] Full Payment - 20% Discount
[2] Installment A - 5% Interest
[3] Installment B - 10% Interest
 
Marshal
Posts: 72088
312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch
How far have you got? Are you getting input at all? Please show us how you are getting that input. If the input is < 5000, can you work out how to handle that situation? How are you coding the “valid” types of input?
 
Master Rancher
Posts: 4194
38
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also posted here: https://www.javaprogrammingforums.com/whats-wrong-my-code/43520-java.html

Please read:  https://coderanch.com/wiki/660346/Wiki/Forthright-Cross-Posting-Sites
 
Christian Gray
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, it's my first time, here is where I'm stuck with.


import java.util.*;

public class TuitionProgram{
static Scanner console = new Scanner (System.in);
public static void main (String args[]){
       int tuition;
int payment;



if (tuition < 5000) {
           System.out.println("Tuition that is less than 5,000 is not allowed.");

       } else {
           System.out.println("Mode of payment");
           System.out.println("[1] Full Payment - 20% Discount");
           System.out.println("[2] Installment A - 5% Interest");
           System.out.println("[3] Installment B - 10& Interest");

           System.out.print("Enter mode of payment: ");
           payment = reads.nextInt();
 
Ranch Hand
Posts: 54
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
payment = reads.nextInt();
I can already imagine the follow up questions, so may let me go ahead: Are you familiar with how to use Scanner and its nextXXX() methods?
 
Christian Gray
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not
 
Norm Radder
Master Rancher
Posts: 4194
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The first problem I see is that the contents of tuition is tested (in an if statement) before it is given a value.
Where is the value in tuition supposed to come from?
 
Carey Brown
Bartender
Posts: 7804
70
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would also like to see the variable named "paymentMethod". "payment" sounds like it should be a monetary amount.

Also, when you post code, please UseCodeTags (<--link). Thanks.
 
Saloon Keeper
Posts: 2828
149
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OP, please select a meaningful topic when creating a post. "Java" does not sound intuitive for a post like this. I changed the topic to a better suitable one. Hope you like it.
 
salvin francis
Saloon Keeper
Posts: 2828
149
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From a user experience standpoint, I don't think "Enter tuition" sounds right. Maybe you want to prompt the user to enter the total fee ? I am also curious about what is the expected output when user selects 2 or 3 from your displayed menu.
 
God is a comedian playing for an audience that is afraid to laugh - Voltair. tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic