Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Student Cables
// C# Basics Exam 14 April 2014 Evening; Student Cables using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { //Your code goes here int num = Console.WriteLine(); long[] cable = new long[num]; string[] type = new string[num]; long result = 0; for (int i = 0; i < num; i++) { cable[i] = Console.WriteLine(); type[i] = Console.WriteLine(); } /*cable[0] = 11; type[0] = "meters"; cable[1] = 18; type[1] = "centimeters"; cable[2] = 8; type[2] = "meters"; cable[3] = 120; type[3] = "centimeters";*/ int sides = cable.Length; for (int i = 0; i < num; i++) { //checks if cable is larger than 20 cm if (cable[i] < 20 && type[i] == "centimeters") { cable[i] = 0; sides--; } if (type[i] == "meters") { cable[i] = cable[i] * 100; } //Console.WriteLine(cable[i]); result = result + cable[i]; } result = result - (sides - 1) * 3; //Console.WriteLine(result); //Creates the new cable long newCable = 504; long numberOfCables = (result / newCable); //Console.WriteLine(numberOfCables); long finalCable = 504 * 3; long leftCable = (result - finalCable); Console.WriteLine(numberOfCables); Console.WriteLine(leftCable); } } }
run
|
edit
|
history
|
help
0
Dependency Injection
Random
Bubble Sort
PermuteAString
Testing 9
Counter-Strike Global Offensive Steam
Variables
asfdfsafasfsa
simpleDelegate
UF pc