Question

In: Computer Science

ONLY USE VISUAL STUDIO (NO JAVA CODING) VISUAL STUDIO -> C# -> CONSOLE APPLICATION In this...

ONLY USE VISUAL STUDIO (NO JAVA CODING)

VISUAL STUDIO -> C# -> CONSOLE APPLICATION

  1. In this part of the assignment, you are required to create a C# Console Application project. The project name should be A3<FirstName><LastName>P2. For example, a student with first name John and Last name Smith would name the project A1JohnSmithP2.

Write a C# (console) program to calculate the number of shipping labels that can be printed on a sheet of paper.

This program will use a menu that includes the following options:

  1. Enter/Update paper size
  2. Enter/Update label size
  3. Generate report
  4. Exit

The first menu option will ask the user to enter the width and height of the paper.

The second menu option will ask the user for the width and height of the label.

The third menu option will calculate the number of whole labels that can fit on the sheet and the report the following:

  1. Paper Size
  2. Label Size
  3. Number of Labels
  4. Total Paper Area (Square inches)
  5. Area used by labels (Square Inches)
  6. Amount of unused paper (Percentage of Total Paper Area)

Your program must:

  1. Have at least 3 methods other than the main method
  2. Handle any potential errors using try/catch statements. The error message output should display at least 3 different types of error (or status) messages, depending on what the user has done incorrectly. Your program should be able to catch all possible errors, it should not crash.
  3. Verify that the user has entered valid data for the paper and label dimensions before the report can be generated.

Print a welcome message including a program description and your name before the menu is displayed

Solutions

Expert Solution

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
class Program
{
static int paperWidth, paperHeight, labelWidht, labelHeight;
static int ch;
static void Main(string[] args)
{
do
{
Console.WriteLine("1. Enter/Update paper size");
Console.WriteLine("2. Enter/Update label size");
Console.WriteLine("3. Generate report");
Console.WriteLine("4. Exit");
try
{
ch = Convert.ToInt32(Console.ReadLine());
}
catch (Exception)
{
Console.WriteLine("Please provide valid integer values for choice");
continue;
}
switch (ch)
{
case 1:
readPaperSize();
break;
case 2:
readLabelSize();
break;
case 3:
generateReport();
break;
case 4:
break;
default:
break;
}
} while (ch != 4);
}

static void readPaperSize()
{
try
{

Console.WriteLine("Enter paper widht:");
paperWidth = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter paper height:");
paperHeight = Convert.ToInt32(Console.ReadLine());
}
catch (Exception)
{
Console.WriteLine("Please provide valid integer values for sizes");
}
}
static void readLabelSize()
{
try
{
Console.WriteLine("Enter label widht:");
labelWidht = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter label height:");
labelHeight = Convert.ToInt32(Console.ReadLine());
}
catch (Exception)
{
Console.WriteLine("Please provide valid integer values for sizes");
}
}
static void generateReport()
{
if (paperHeight == 0 || paperWidth == 0)
{
Console.WriteLine("Please provide paper size");
return;
}
if (labelHeight == 0 || labelWidht == 0)
{
Console.WriteLine("Please provide label size");
return ;
}
if (paperHeight < labelHeight)
{
Console.WriteLine("Label hight cannot be greater than paper size");
return;
}
if (paperWidth < labelWidht)
{
Console.WriteLine("Label width cannot be greater than paper size");
return;
}
Console.Write("Paper size: %d * %d", paperHeight, paperWidth);
Console.Write("Label size: %d * %d", labelHeight, labelWidht);
int paperArea = paperHeight * paperWidth;
int labelArea = labelHeight * labelWidht;
int totalLabels = paperArea / labelArea;
Console.Write("Total labels: %d", totalLabels);
Console.Write("Total Paper Area (Square inches): %d", paperArea);
Console.Write("Area used by labels (Square Inches): %d", labelArea * totalLabels);
Console.Write("Amount of unused paper (Percentage of Total Paper Area): %f", (paperArea / (labelArea * totalLabels)) * 100);

}
}
}


Related Solutions

answer the following using C# Design and program a Visual Studio Console project in C# that...
answer the following using C# Design and program a Visual Studio Console project in C# that allows your user to enter a number. The program will examine the number to see if it is prime. If it is prime, it will print the next higher prime and the next lower primes to the console. If the number entered by the user is not prime, display a message to that effect. All code should be written by you. Do not copy/paste...
Create a C# .NET Core Console project in Visual Studio. (This is the same kind of...
Create a C# .NET Core Console project in Visual Studio. (This is the same kind of project we have been doing all semester.) Do all of the following in the Program class. You do not need to add any other classes to this project. 2. If it exists, remove the Console.WriteLine(“Hello World!”); line that Visual Studio created in the Program class. 3. At the very top of the Program.cs page you should see using System; On the empty line below...
Create a Visual Studio console project (c++) containing a main() program that declares a const int...
Create a Visual Studio console project (c++) containing a main() program that declares a const int NUM_VALUES denoting the array size. Then declare an int array with NUM_VALUES entries. Using a for loop, prompt for the values that are stored in the array as follows: "Enter NUM_VALUES integers separated by blanks:" , where NUM_VALUES is replaced with the array size. Then use another for loop to print the array entries in reverse order separated by blanks on a single line...
Write a C program The Visual Studio project itself must make its output to the Console...
Write a C program The Visual Studio project itself must make its output to the Console (i.e. the Command Prompt using printf) and it must exhibit the following features as a minimum: 3%: Looping Menu with 3 main actions: View Cars, Sell Car, View Sales Note: A Car is defined by its price and model 3%: Must contain at least three arrays to record sales figures (maximum of 10 Car models) Two for recording the price and model of one...
Using Visual Studio in C#; create a grading application for a class of ten students. The...
Using Visual Studio in C#; create a grading application for a class of ten students. The application should request the names of the students in the class. Students take three exams worth 100 points each in the class. The application should receive the grades for each student and calculate the student’s average exam grade. According to the average, the application should display the student’s name and the letter grade for the class using the grading scheme below. Grading Scheme: •...
Make a Program in Visual Studio / Console App (.NET Framework) # language Visual Basic You...
Make a Program in Visual Studio / Console App (.NET Framework) # language Visual Basic You will be simulating an ATM machine as much as possible Pretend you have an initial deposit of 1000.00. You will Prompt the user with a Main menu: Enter 1 to deposit Enter 2 to Withdraw Enter 3 to Print Balance Enter 4 to quit When the user enters 1 in the main menu, your program will prompt the user to enter the deposit amount....
Create a Visual Studio console project using c++ void lowerToUpper(std::string & sentence) that iterates over all...
Create a Visual Studio console project using c++ void lowerToUpper(std::string & sentence) that iterates over all characters in the sentence argument. Any lowercase letter should be converted to uppercase. This can be done by including <cctype> and testing each character in sentence with the islower() function. If islower(sentence[i]) returns true then sentence[i] should be replaced with toupper(sentence[i]). The main() function should assign "Hello how are you doing?" to sentence, call lowerToUpper(sentence), and use an if statement to check the new...
MUST BE DONE IN C++ Use qsort( ) function in Visual Studio to sort the following...
MUST BE DONE IN C++ Use qsort( ) function in Visual Studio to sort the following three arrays: int array1 [] = { 3, 4, 2, 1, 7}; float array2 [] = {0.3, 0.1, 5.5, 4.3, 7.8}; char array3 [] = {‘c’, ‘d’, ‘a’, ‘b’, ‘f’};                                     Develop a driver function to print out the sorted results and put the screenshot into the word document. Note that you have to use qsort( ) provided by Visual Studio. What is the...
1. Make a Console App (.NET Core) in Visual Studio and name it as A1YourFirstnameLastname. 2....
1. Make a Console App (.NET Core) in Visual Studio and name it as A1YourFirstnameLastname. 2. Implement a vehicle rental management system which is capable of doing the following: • View all, available and reserved vehicles. • Reserve vehicle or cancel a reservation. 3. The application must be menu-based app: 1 - View all vehicles 2 - View available vehicles 3 - View reserved vehicles 4 - Reserve a vehicle 5 - Cancel reservation 6 - Exit 4. NOTE: At...
Create a C++ project in visual studio. You can use the C++ project that I uploaded...
Create a C++ project in visual studio. You can use the C++ project that I uploaded to complete this project. 1. Write a function that will accept two integer matrices A and B by reference parameters, and two integers i and j as a value parameter. The function will return an integer m, which is the (i,j)-th coefficient of matrix denoted by A*B (multiplication of A and B). For example, if M = A*B, the function will return m, which...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT