VIII. Summarize the names and ages in three-column-format For Example, Tom Doe 30 Lisa Young 27 name Age name Manika Baker Tim Robinson Age 25 25 name Jack Jordan Roger Mayes Age 31 34 Compile your file and fix the syntax errors. Run your program to check the logical errors.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
The language is Java
VIII. Summarize the names and ages in three-column-format
For Example,
Tom Doe
30
Lisa Young
27
name
Age
name
Manika Baker
Tim Robinson
Age
25
25
name
Jack Jordan
Roger Mayes
Age
31
34
Compile your file and fix the syntax errors.
Run your program to check the logical errors.
Transcribed Image Text:VIII. Summarize the names and ages in three-column-format For Example, Tom Doe 30 Lisa Young 27 name Age name Manika Baker Tim Robinson Age 25 25 name Jack Jordan Roger Mayes Age 31 34 Compile your file and fix the syntax errors. Run your program to check the logical errors.
Expert Solution
Step 1:Explanation

Program has two string variables to store names.

It also has two integer variables to store ages.

System.out.print is used to print the values to the output.

Scanner is used to read the values from the input.

Values are printed to the screen using the width and precision values of the string format.

For example %20.10s, specifies that there are total 20 pads from current position and 10 specifies that there should be 10 characters of the string which must be printed right aligned.

Step 2:Program

import java.util.Scanner;
public class Main
{
  public static void main (String[]args)
  {
       String yourName,bestFriendsName; //declaring variables to store names
       int yourAge,bestFriendsAge; //declaring variables to store ages
       Scanner myobj = new Scanner (System.in);
    
      System.out.print(" Enter a  Your Name:");
      yourName = myobj.nextLine(); //storing your name
      System.out.print(" Enter a  Your best friends Name:");
      bestFriendsName = myobj.nextLine();//storing friends name
      
      
      System.out.print(" How old is "+yourName+"?");
      yourAge = myobj.nextInt();//storing your age
      System.out.print(" How old is "+bestFriendsName+"?");
      bestFriendsAge = myobj.nextInt();//storing friends age
      
      System.out.printf("%10.10s  %30.30s %30.30s%n", "name", yourName,bestFriendsName);
      System.out.printf("%10.10s  %30.30s %30.30s%n", "age", yourAge, bestFriendsAge);

   }
}

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Introduction to computer system
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education