Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
C#
using System;

namespace PrintPrice
{
    class Price
    {
        const int maximumLineNumber = 50;
        const int pageLength = 20;
        const int pricePerLicense = 1100;
        const int packageOfLicenses = 10;

        static void Main()
        {
            int lineNumber;
            int quantityOfLicenses;
            int totalForLicenses;
            int pricePerLicense;
            int maximumLineNumber;
            int pageLength;
            int packageOfLicenses;

            Console.Write("Enter a price per license: ");
            if (!int.TryParse(Console.ReadLine(), out pricePerLicense))
            {
                pricePerLicense = Price.pricePerLicense;
                Console.WriteLine("Automatically the price per license is: " + pricePerLicense);
                Console.WriteLine();
            }

            Console.Write("Enter a maximum line number: ");
            if (!int.TryParse(Console.ReadLine(), out maximumLineNumber))
            {
                maximumLineNumber = Price.maximumLineNumber;
                Console.WriteLine("Automatically the maximum line number is: " + maximumLineNumber);
                Console.WriteLine();
            }

            Console.Write("Enter a page length per output: ");
            if (!int.TryParse(Console.ReadLine(), out pageLength))
            {
                pageLength = Price.pageLength;
                Console.WriteLine("Automatically the page length per output is: " + pageLength);
                Console.WriteLine();
            }

            Console.Write("Enter a package of licenses: ");
            if (!int.TryParse(Console.ReadLine(), out packageOfLicenses))
            {

                packageOfLicenses = Price.packageOfLicenses;
                Console.WriteLine("Automatically the package of licenses is: " + packageOfLicenses);
                Console.WriteLine();
            }


;
            int discount = 3500;
            int numberOfLicenses = 1;
            for (lineNumber = 1; lineNumber <= maximumLineNumber; lineNumber++)
            {
                if (packageOfLicenses == (10 * numberOfLicenses))
                {

                    discount = 3500 * lineNumber;
                    quantityOfLicenses = packageOfLicenses * lineNumber; /* Assuming packageOfLicenses=10, we print price of 10 licenses on line 1, and 20 licenses on line 2, …*/
                    totalForLicenses = quantityOfLicenses * pricePerLicense;
                    Console.WriteLine("Line " + lineNumber + ": "
                                              + quantityOfLicenses + " Licenses "
                                              + "cost " + (totalForLicenses - discount));

                }
 
                

                if ((lineNumber % pageLength) == 0) Console.ReadKey(); /* pause after every page printed */
            }

            Console.ReadKey();
        }
    }
}


please someone help me with this. :(
i need the output like this
10 licenses costs only 7500
20 licenses costs only 15000

line 1: licence PHP 1100
line 2: licenses PHP 2200
line 3: licenses PHP 3300
line 4: licenses PHP 4400
line 5: licenses PHP 5500
line 6: licenses PHP 6600
line 7: licenses PHP 7700
line 8: licenses PHP 8800
line 9: licenses PHP 9900
line 10: licenses PHP 7500
line 11: licenses PHP 8600
line 12: licenses PHP 9700
:
line 300 licenses PHP ….
Posted
Updated 22-Dec-11 22:56pm
v2
Comments
R. Giskard Reventlov 23-Dec-11 4:58am    
This looks suspiciously like a homework assignment. We don't do homework.
[no name] 24-Dec-11 0:44am    
it's not a homework. im just trying to figure out why my codes is not working. I am new in this language. that is why i am asking for any ideas how i can solve it.
Laxman Auti 23-Dec-11 5:05am    
The answer is in your question (a simple code), why don't you try it once?
Drazen Pupovac 23-Dec-11 5:15am    
What is question exactly?

This shouldn't even compile because you've declared some of the variables twice.

C#
const int maximumLineNumber = 50;
const int pageLength = 20;
const int pricePerLicense = 1100;
const int packageOfLicenses = 10;

static void Main()
{
    int maximumLineNumber;
    int pageLength;
    int pricePerLicense;
    int packageOfLicenses;


Delete your const definitions. They're completely unnecessary.
 
Share this answer
 
Comments
[no name] 24-Dec-11 0:26am    
i need the constant because when i press the enter w/out value the constant value will take over the place.
Just change this much part and its working fine
C#
int discount = 3500;
            int numberOfLicenses = 1;
            string val = "";
            for (lineNumber = 1; lineNumber <= maximumLineNumber; lineNumber++)
            {
                if (packageOfLicenses == (10 * numberOfLicenses))
                {

                    discount = 3500 * lineNumber;
                    quantityOfLicenses = packageOfLicenses * lineNumber; /* Assuming packageOfLicenses=10, we print price of 10 licenses on line 1, and 20 licenses on line 2, …*/
              totalForLicenses = quantityOfLicenses * pricePerLicense;
              if (lineNumber % 10 == 0)
              {
                val = val + "\n Line " + lineNumber + ": "
               + quantityOfLicenses + " Licenses " +
                "cost " + (totalForLicenses - discount);
              }

                }

                if ((lineNumber % pageLength) == 0) Console.ReadKey(); /* pause after every page printed */
            }


            Console.Write(val);
            Console.ReadKey();
        }
 
Share this answer
 
Comments
[no name] 24-Dec-11 1:27am    
thanks for the idea. i try a lot of possible ideas but i can't get it right.
Anuja Pawar Indore 26-Dec-11 1:01am    
WC :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900