zǝɥɔsdɹoʇ
zǝɥɔsdɹoʇ
CC#
Created by zǝɥɔsdɹoʇ on 2/24/2024 in #help
✅ not sure why my if else code isnt displaying what it should be
I am making a console application that is supposed to allow the user to enter the prices of items and if -999 is entered it will display the total price without tax and shipping but the code for shipping doesnt seem to work
5 replies
CC#
Created by zǝɥɔsdɹoʇ on 2/21/2024 in #help
cant figure out how to calculate averages
using System; namespace MyApp { internal class Program { static void Main(string[] args) { Intro(); double test1 = score1("Please enter the score of the first test"); while (test1 > -999) { test1 = score1("Please enter the score of your test"); } double total = grade(test1); letter(total); Ending(); } public static void Intro() { Console.Title = ("EX38"); Console.WindowHeight = 15; Console.WindowWidth = 60; Console.ForegroundColor = ConsoleColor.Green; } public static double score1(string s) { Console.WriteLine(s); double test1 = Convert.ToDouble(Console.ReadLine()); return test1; } public static double grade(double test1) { double total = (test1+999) / 5; Console.WriteLine("The average of the grades is {0:f1}", total); return total; } public static void letter(double total) { if (total > 89) { Console.WriteLine("This is an A"); } if (total < 89 && total > 79) { Console.WriteLine("This is an B"); } if (total < 79 && total > 69) { Console.WriteLine("This is an C"); } if (total < 69 && total > 59) { Console.WriteLine("This is an D"); } if (total < 59) { Console.WriteLine("This is an F"); } } public static void Ending() { Console.SetCursorPosition(Console.WindowWidth / 2 - 15, Console.WindowHeight - 2); Console.WriteLine("Press enter twice to close window."); Console.ReadLine(); } } }
53 replies