-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrimeFactorsApp
95 lines (92 loc) · 2.31 KB
/
PrimeFactorsApp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using Ch04Ex02PrimeFactorsLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
WriteLine("Hello! Welcome to the Prime Factors Application. You can use this application to identify all the prime factors of any integer under 1,001.");
RallyPoint:
WriteLine();
Write("Please enter a whole number that you would like to factorize: ");
double userinput = 0;
try
{
userinput = Convert.ToDouble(ReadLine());
}
catch (Exception ex)
{
WriteLine($"{ex.GetType} says {ex.Message}");
goto RallyPoint;
}
WriteLine();
if (userinput > 1 && userinput < 1001)
{
PFLib thisinstance = new();
thisinstance.primeFactors(userinput);
}
else if (userinput > 1000)
{
WriteLine($"{userinput} is too large for this application! The maximum value is 1,000. Would you like to try again?");
WriteLine();
string? answer1 = Console.ReadLine();
if (answer1 == "Yes")
{
goto RallyPoint;
}
else if (answer1 == "No")
{
WriteLine("Thank you for using the prime factors app! Goodbye.");
ReadKey();
}
else if (answer1 != "Yes" || answer1 != "No")
{
WriteLine();
WriteLine("I'm sorry, I can't understand your answer.");
goto RallyPoint2;
}
}
else if (userinput <= 1)
{
Console.WriteLine($"{userinput} does not have any prime factors!");
WriteLine();
WriteLine("Would you like to try again?");
WriteLine();
string? answer2 = Console.ReadLine();
if (answer2 == "Yes")
{
goto RallyPoint;
}
else if (answer2 == "No")
{
WriteLine("Thank you for using the prime factors app! Goodbye.");
ReadKey();
}
else if (answer2 != "Yes" || answer2 != "No")
{
WriteLine();
WriteLine("I'm sorry, I can't understand your answer.");
goto RallyPoint2;
}
}
WriteLine();
RallyPoint2:
WriteLine();
WriteLine("Would you like determine the factors of another number?");
WriteLine();
string? answer3 = ReadLine();
if (answer3 == "Yes")
{
goto RallyPoint;
}
else if (answer3 == "No")
{
WriteLine();
WriteLine("Thank you for using the prime factors app! Goodbye.");
return;
}
else if (answer3 != "Yes" || answer3 != "No")
{
WriteLine();
WriteLine("I'm sorry, I can't understand your answer.");
goto RallyPoint2;
}