Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Im on the right way or not?

  1. #1
    Junior Member
    Join Date
    Jul 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Im on the right way or not?

    Hi everyone!
    I must write a code however i have no idea how to do this.
    First screen How it should be.
    Second is my code.
    Could you tell me please smth
    Actually i do not understand what im doing and just have a write code from lecture slides.

    P.s NUMBER_OF_CARS” should be equal to the highest digit in your student ID. My is 6

    import java.util.Scanner;
     
    public class ReadingRegistrarion
    	{
    		public static void main( String args[] )
    		{
    			Scanner input = new Scanner( System.in);
     
    			int number1;
    			int number2;
    			int number3;
    			int number4;
    			int number5;
    			int number6;
     
    			System.out.print( "Enter the registration car number 1" );
    			number1 = input.nextInt();
    			System.out.print( "Enter the registration car number 2" );
    			number2 = input.nextInt();
    			System.out.print( "Enter the registration car number 3" );
    			number3 = input.nextInt();
    			System.out.print( "Enter the registration car number 4" );
    			number4 = input.nextInt();
     			System.out.print( "Enter the registration car number 5" );
    			number5 = input.nextInt();
    			System.out.print( "Enter the registration car number 6" );
    			number6 = input.nextInt();
     
    			System.out.printf
     
     
    public class CarInsurance
    {
    	public void processCars()
    	{
    	}
     
    	private double calculateFee(int inputAge)
    	{
    	}
     
    	private double calculateDiscount(double originalFee, boolean accident)
    	{
    	}
     
    	private boolean requestAccidentHistory()
    	{
    	}
     
    	private void finalOutput()
    	{
    	}
     
    	public static void main(String[] args)
    	{
    		CarInsurance carInsurance = new CarInsurance();
    		carInsurance.processCars();
    	}
    }


    You work for the local car insurance company, Motorcity. Your boss decided that the company is ready to expand and wants a small program to help the local offices calculate insurance quotes for a high volume of cars.

    You are asked to write a Java Console Application (CarInsurance class) which will accept details for a fixed number of cars. The number of cars should be represented by a constant “NUMBER_OF_CARS” in your program.

    “NUMBER_OF_CARS” should be equal to the highest digit in your student ID, use NUMBER_OF_CARS=3 if your highest digit is less than 3. For example, if your student ID is S0343126, NUMBER_OF_CARS should be equal to 6.

    The details for each car to be input are their
    1. car registration (license plate) number,
    2. age
    3. and whether the car had been in an accident before

    If a car had never been in an accident before, a 25% discount off its insurance cost should be applied.

    The pricing structure for Motorcity’s car insurance is as follows:

    • Cars over 5 years old will cost $350.00.
    • Cars less than and up till 5 years old will cost $200.00.

    A meeting with your boss produced the following draft of how the program should run:

    For “NUMBER_OF_CARS” number of cars:
    1. Enter the car registration number
    2. Enter the age of the car
    3. Enter “y”, “Y”, “n” or “N” for car accident history. (Assume no other input is possible)
    4. The application will calculate and display the discount (if applicable) and the total cost of the insurance less the discount, and then display these details to the user on the screen.
    For example, the following output would be ideal:





    5. If there is no discount then just the final insurance fee will be displayed




    Finally when all the cars have been entered, a summary should be displayed.
    The following should be included in the summary:
    a) the number of cars entered
    b) the total discounts given
    c) the total insurance paid
    d) and the average insurance paid
    (see sample output below).

    Also display a closing message which includes your student ID (see sample output below).
    Numeric results should be displayed with suitable precision, for example use two decimal places for currency and percentage amounts.
    Attached Images Attached Images
    • File Type: jpg 2.jpg (112.7 KB, 5 views)
    • File Type: jpg 1.jpg (94.8 KB, 8 views)
    Last edited by mihrutkanik; July 27th, 2014 at 07:43 AM.

  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Im on the right way or not?

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    Please post your code directly into a post using code or highlight tags which are explained near the top of the above link.

    Further, we need to understand the requirements you're working to, and I don't think you've communicated that yet.