Answer to Question #193656 in Java | JSP | JSF for Francina

Question #193656

An estate agency sells and rents out properties. Each property listed at the company has a property code and is assigned to an estate agent. The property code consists of 10 digits e.g. 1312122019. The first digit indicates whether the property is for sale (1) or available for renting (2). The second digit indicates whether it is a business property (> 2) or a residential property (<= 2). Properties that are for sale has a selling price while properties to be rented out has a rent amount (per month) and a value that indicates the duration of the contract


 



1
Expert's answer
2021-05-15T13:47:03-0400
import java.util.Scanner;


public class Q193656 {
    public static void main(String[] args) {
       Scanner input = new Scanner(System.in);
        
        System.out.print("Enter the property code: ");
        String propertyCode = input.nextLine();
        //The first digit indicates whether the property is for 
        //sale (1) or available for renting (2).
        if(Integer.parseInt(String.valueOf(propertyCode.charAt(0)))==1){
          System.out.println("The property is for sale");
        }
        if(Integer.parseInt(String.valueOf(propertyCode.charAt(0)))==2){
          System.out.println("The property is for renting");
        }
        
        //The second digit indicates whether it 
        //is a business property (> 2) or a residential property (<= 2).
        if(Integer.parseInt(String.valueOf(propertyCode.charAt(1)))>2){
          System.out.println("It is a business property.");
        }
        if(Integer.parseInt(String.valueOf(propertyCode.charAt(1)))<=2){
          System.out.println("It is a residential property.");
        }
        
        input.close();
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS