1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
scoundrel [369]
3 years ago
5

Assume that name and age have been declared suitably for storing names (like "Abdullah", "Alexandra" and "Zoe") and ages respect

ively. Write some code that reads in a name and an age and then prints the message "The age of NAME is AGE." where NAME and AGE are replaced by the values read in for the variables name and age. For example, if your code read in "Rohit" and 70 then it would print out "The age of Rohit is 70.".
Computers and Technology
1 answer:
Irina18 [472]3 years ago
3 0

Answer:

import java.util.Scanner;

public class num2 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter Name");

       String name = in.next();

       System.out.println("Enter Age");

       int age = in.nextInt();

       System.out.println("The age of "+name +" is "+age);

   }

}

Explanation:

Java programming language is used to write the code.

The scanner class is used to prompt and receive values for name and age which are stored in the appropriate variables.

The key idea here is using string concatenation in the output statement in order to print the desired output

You might be interested in
To prevent rust from forming, a light coating of_____should be applied to all machined surfaces
Fantom [35]
What is that I never heard of that before
4 0
3 years ago
Write a program that asks the user for the number of males and the number of females registered in a class. The program should d
Bond [772]

Answer:

import java.util.Scanner;

public class PercentagePopulation {

public static void main(String[] args) {

 // 1. Create an object of the Scanner class

 // This will allow for user's inputs

 Scanner input = new Scanner(System.in);

 // 2. Create a prompt asking the user to enter the number of males

 System.out.println("Please enter the number of males");

 // 3. Receive the number entered by the user and store in an int

 // variable called  number_of_males.

 int number_of_males = input.nextInt();

 // 4. Create a prompt asking the user to enter the number of

               // females

 System.out.println("Please enter the number of females");

 // 5. Receive the number entered by the user and store in an int

 // variable  called, number_of_females

 int number_of_females = input.nextInt();

 // 6. Find the sum of the number of males and females

 // Store the result in an int variable called total.

 int total = number_of_males + number_of_females;

 // 7. Find the percentage of males by using the appropriate

 // formula.  Do a type-casting to allow for division in floating point

               // representation by prepending the number_of_males by (double)

 double percentagemales = (double) number_of_males / total * 100.0;

 // 8. Find the percentage of females by using the appropriate

 // formula.  Do a type casting to allow for division in floating point

               // representation by prepending the number_of_males by (double)

 double percentagefemales = (double) number_of_females / total * 100.0;

 // 9. Print out the results

 System.out.println("Percentage males : " + percentagemales + "%");

 System.out.println("Percentage females : " + percentagefemales + "%");

}

}

Explanation:

Please go through the comments in the code to give an explanation of the program. The source code file has also been added to this response. Please download it and go through it.

Download java
4 0
3 years ago
Which service uses a broadband connection?
Sidana [21]

Answer:

d

Explanation:

because all in one question form

5 0
3 years ago
Question 5 of 10
Drupady [299]
The programs you need for you are not even done yet
3 0
1 year ago
Choose the 3 Points in good story telling
Sidana [21]

Answer:

1.Choose a clear central message 2. Embrace conflict 3.Have a clear structure  

Explanation:

8 0
2 years ago
Other questions:
  • Which connector is most commonly used to connect printers to desktop pc systems?
    10·1 answer
  • Write c program to check character is alphabate or not?​
    15·1 answer
  • What is the use of word art?
    10·1 answer
  • Drivers should scan 10-12 secound down the road looking of potential hazards
    5·1 answer
  • python (Business: check ISBN-10) An ISBN-10 (International Standard Book Number) consists of 10 digits: d1d2d3d4d5d6d7d8d9d10. T
    12·1 answer
  • Consider the following code segment. int[] seq = {3, 1, 8, 4, 2, 5}; for (int k = 1; k < seq.length; k++) { if (seq[k] >=
    5·1 answer
  • What are the advantages and disadvantages of fortran?
    13·1 answer
  • Write HTML code for inserting an image "cricket.jpeg" in size 500 width and 400 height.
    12·1 answer
  • 1. If an F# function has type 'a -> 'b when 'a : comparison, which of the following is not a legal type for it? Select one:
    14·1 answer
  • Do debit cards offer the highest level of fraud pretection?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!