Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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. Frown | :(
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 22-Dec-11 23:55pm
Edited 22-Dec-11 23:56pm
v2
Comments
mark merrens at 23-Dec-11 4:58am
   
This looks suspiciously like a homework assignment. We don't do homework.
cyniel magarcenio at 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 at 23-Dec-11 5:05am
   
The answer is in your question (a simple code), why don't you try it once?
Drazen Pupovac at 23-Dec-11 5:15am
   
What is question exactly?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

This shouldn't even compile because you've declared some of the variables twice.
 
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.
  Permalink  
Comments
cyniel magarcenio at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Just change this much part and its working fine
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();
        }
  Permalink  
Comments
cyniel magarcenio at 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 at 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)

  Print Answers RSS
0 BillWoodruff 360
1 Mathew Soji 309
2 DamithSL 225
3 Afzaal Ahmad Zeeshan 202
4 Maciej Los 190
0 OriginalGriff 6,249
1 Sergey Alexandrovich Kryukov 5,853
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 3,865


Advertise | Privacy | Mobile
Web01 | 2.8.1411019.1 | Last Updated 23 Dec 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100