Question

In: Computer Science

Using the main function’s arguments, create a program that takes in a person’s name, their home...

Using the main function’s arguments, create a program that takes in a person’s name, their home town/location, and cell number then prints out the following message:

Sample run 1:

Java lab01_task03 Sililo Uis 0819876543

Output:  

Contact successfully saved !!

Contact Name : Sililo @ Uis

Home number: 0819876543

Solutions

Expert Solution

Below is the code in JAVA for the requirements mentioned in the question. We have to use the command line arguments as mentioned in the question. So for that we already know that the main() function accepts command line arguments in String args[] array. So we have to just use the appropriate indices to retrieve the data from this array of strings. For our question we give the command line arguments in the sequence - name, hometown and contact number. So, args[0] will correspond to name, args[1] will correspond to hometown and args[2] will correspond to contact number. We just used this to write the program below and printed the output. We have attached the screenshot of the program and also the screenshot of sample output at the end.

public class Main
{
        public static void main(String[] args) {
            
                System.out.println("Output:");
                System.out.println("Contact successfully saved !!");
                
                
        System.out.println("Contact Name: "+args[0]+" @ "+args[1]);
        System.out.println("Home Number: "+args[2]);
                
        }
}

Screenshot of program:-

Sample Output:-


Related Solutions

4. Create a program that takes in the following CMD arguments: Item name, quantity, cost per...
4. Create a program that takes in the following CMD arguments: Item name, quantity, cost per item, and total cost. Your task then is to take this given information to print a simple receipt as indicated below (Don’t worry about the calculations for now.) 1 Sample run 1: Java lab01_task04 Banana 6 3.25 19.50 Output: Welcome to FCI Fresh Goods Sales ====================== You have purchased: 6 X Banana @ N$ 3.25 including 15% VAT ====================== Total Cost: N$ 19.50 ======================
16.15 Lab 5: filter Name this program filter.c. The program takes two command line arguments: the...
16.15 Lab 5: filter Name this program filter.c. The program takes two command line arguments: the name of an input file and the name of an output file. The program should confirm the input and output files can be opened. If a file cannot be opened, print the error message Cannot open file '<filename>' where <filename> is the name of the file and return. fopen() will return 0 if it fails to open a file. Then, the program will read...
** USING MATLAB TO PROGRAM The main objective of this lab is to create a game...
** USING MATLAB TO PROGRAM The main objective of this lab is to create a game that involves betting on the sum of two dice. The player will start out with some initial total amount of money. During each round, the player can bet some money that the sum of the two dice will be equal to a certain number. If the player wins the bet, that player adds the amount of the bet to his or her current total....
Write a program that takes two command line arguments at the time the program is executed....
Write a program that takes two command line arguments at the time the program is executed. You may assume the user enters only decimal numeric characters. The input must be fully qualified, and the user should be notified of any value out of range for a 23-bit unsigned integer. The first argument is to be considered a data field. This data field is to be is operated upon by a mask defined by the second argument. The program should display...
Write a program that contains a function that takes in three arguments and then calculates the...
Write a program that contains a function that takes in three arguments and then calculates the cost of an order. The output can be either returned to the program or as a side effect. 1. Ask the user via prompt for the products name, price, and quantity that you want to order. 2. Send these values into the function. 3. Check the input to make sure the user entered all of the values. If they did not, or they used...
Using the code below from “LStack.h” file, write the code for a main program that takes...
Using the code below from “LStack.h” file, write the code for a main program that takes as input an arithmetic expression. The program outputs whether the expression contains matching grouping symbols. For example, the arithmetic expressions { 25 + ( 3 – 6 ) * 8 } and 7 + 8 * 2 contains matching grouping symbols. However, the expression 5 + { ( 13 + 7 ) / 8 - 2 * 9 does not contain matching grouping symbols....
I need someone to create a program for me: Create a program that takes as input...
I need someone to create a program for me: Create a program that takes as input an employee's salary and a rating of the employee's performance and computes the raise for the employee. The performance rating here is being entered as a String — the three possible ratings are "Outstanding", "Acceptable", and " Needs Improvement ". An employee who is rated outstanding will receive a 10.2 % raise, one rated acceptable will receive a 7 % raise, and one rated...
Create a c program that takes 1 parameter, a number using that number, dynamically allocate a...
Create a c program that takes 1 parameter, a number using that number, dynamically allocate a memory so you store that number of integers write integers in order starting from 1 until you fill all that memory print the address and values of the first and the last integer stored in the memory
Create a program with the Calculator.java code RUN the program with the invalid data arguments 1,...
Create a program with the Calculator.java code RUN the program with the invalid data arguments 1, 3, 5x Take a screenshot of the output and describe what you think happened. MODIFY the code as in listing 14.2, NewCalculator.java , RUN it again with the same invalid input Take a screenshot of the new output and describe in your word document why you think the exception handling is a 'better' programming technique than just letting the program crash. __________________________________________________________________________ The Calculator.java...
create a code in JAVA that takes arguments to do a bfs(breadth first search) or a...
create a code in JAVA that takes arguments to do a bfs(breadth first search) or a dfs( depth first search) using a txt file as the graph input. I have made most of the main function as well as a nose function I just need the bfs and dfs functions to work here's what I have so far, the comments that start with TODO are the parts that I need to finish Main.java import java.io.*; import java.util; ArrayList; import java.util.Iterator;...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT