Question

c++ assignment about command line

Write a program that uses command-line processing to get a number of integers and then print them out in descending order. The number of input integers is limited to 5 ; otherwise, an error message should be displayed. A sample output is shown below:

image.png


I still cant figure out how to do the c++ command line assignment on visual studios so help me with the full coding asap.


Keep in mind the program should be a beginner's level and dont make it complicated so it makes it easier to read as a beginner

2 0
Add a comment Improve this question
Answer #1

public class Command_line_argument {

    

    public static void main(String arg[])

    

    {

        

        // Get how many input are there

        

        int n = arg.length;

        

        if(n >5 )

        

        System.out.println("You cannot input more than 5 integers.");

        

        //Now check every input is string

        

        try {

            

            for(int i=n-1;i>=0;i--)

            

            System.out.print(Integer.parseInt(arg[i])+ " ") ;

            

            System.out.println();

            

        } catch (Exception e) {

            

            System.out.println("Invalid Input.");

            

        }

        

    }

    

}


answered by: codegates
Add a comment
Know the answer?
Add Answer to:
c++ assignment about command line
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Help about c++ assignment, the due date was very soon right now

    I am still struggling to do this assignment using c++ visual studios right now, i need help before the deadlineThe questions are in the google docs and I need help now because the due date was very soon at the 30th of November 2021 so I need help as soon as possible about the program on visual studios c++ and make the program quick before the due date right now.Now I got 11 people request to get the answer on...

  • C++ assignment about File processing

    You are the owner of a hardware store and need to keep an inventory that can tell you what different tools you have, how many of each you have on hand and the cost of each one.(a)  Write a program that initializes the sequential file hardware.txt, lets you input the data concerning each tool, enables you to list all your tools, lets you delete a record for a tool that you no longer have and lets you update anyinformation in...

  • c++ assignment array due tomorrow

    The c++ assignment is due tomorrow and I need help today right now as soon as possible so I can hand in the assignment before tomorrow. Here are the questions on the pictures.Keep in mind the c++ program on visual studios should be easy to read as a beginner and the program must be beginners level.

  • This is a standard C++ programming assignment using a command line g++ compiler or the embedded...

    This is a standard C++ programming assignment using a command line g++ compiler or the embedded one in zyBooks. No GUI forms and no Visual Studio. No external files and no databases are used. There is only one object-oriented program to complete in this assignment. All code should be saved in a file named ExamScoresUpdate.cpp, which is the only file to submit for grading. No .h files used. The .cpp file contains main() and two classes, ExamScores and DataCollector. There...

  • Your task is to write a C++ program that consumes integer values as command line arguments...

    Your task is to write a C++ program that consumes integer values as command line arguments and returns the arithmetic mean of these values. To increase the flexibility of the program, there should be no set number of arguments. To overcome this, we will require the argument argv[1] to be the number of integers the user enters. For example, if the user wants to calculate the arithmetic mean of 4 numbers, they would pass in 4 as the first argument...

  • C++ assignment about doubly linked list

    You are required to write the following functions using this class: class Doubly_linked_list // Use a class Doubly_linked_list to represent an object {     public:     // constructor initialize the nextPtr     Doubly_linked_list()     {         prevPtr = 0; // point to null at the beginning         nextPtr = 0; // point to null at the beginning     }     // get a number     int GetNum()     {         return number;     }     // set a number     void SetNum(int num)     {         number = num;     }     // get the prev pointer     Doubly_linked_list ...

  • All commands must be in the command line. The expense data file is separate. Programming Project...

    All commands must be in the command line. The expense data file is separate. Programming Project #2: Manage Spending Using Commands Objectives: • Understand how to create and manipulate list of objects using array or vector class • Handle input errors and invalid values • Design and create a well-structure program using C++ basic programming constructs and classes. Description: Each “expense” contains 2 values: the spending amount (double) and its description (string) Here is an example of the “expense” data...

  • Assignment: Write a program in C++ that allows a customer to go on-line shopping. This is...

    Assignment: Write a program in C++ that allows a customer to go on-line shopping. This is a start-up venture and the stock of our on-line company is currently limited to the following items: A gift card to Home Depot, $50.00 A bottle of cologne (The One by Dolce Gabbana), $24.00 3. Akeychainwithabathtubornament,$14.00 4. Acard,$4.00 Although all items are in stock, the customer should only be made aware of the items that he or she can afford. In addition, demand for...

  • C++ Programming From Problem Analysis to Program Design

    I'm having trouble with this one problem and I need some help. I'm a beginner at C++ so please go easy on me.To make telephone numbers easier to remember, some companies use letters to show their telephone number. For example, using letters, the telephone number 438-5626 canbe shown as GET LOAN. In some cases, to make a telephone number meaningful, companies might use more than seven letters. For example, 225-5466 can be displayed as CALLHOME, which uses eight letters. Write...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT