- 2

[solved] C# final code project, need help

I'm trying to solve the project like in the lesson before but I can't make it work. I get exceptions without specific lines mentioned. Any help is welcome. Task: A discount is given and the dictionary should update and print the new prices. Code: int discount = Convert.ToInt32(Console.ReadLine()); Dictionary<string, int> coffee = new Dictionary<string, int>(); coffee.Add("Americano", 50); coffee.Add("Latte", 70); coffee.Add("Flat White", 60); coffee.Add("Espresso", 60); coffee.Add("Cappuccino", 80); coffee.Add("Mocha", 90); //your code goes here foreach(string s in coffee.Keys){ coffee[s] = coffee[s]/100 *(100-discount); Console.WriteLine(s+" :"+coffee[s]); }

3rd Dec 2021, 9:54 AM
Lena Morawietz
Lena Morawietz - avatar
4 Respostas
+ 3
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { int attendance = Convert.ToInt32(Console.ReadLine()); int avgScore = Convert.ToInt32(Console.ReadLine()); //your code goes here if(attendance>=95&& avgScore>=8 ) { Console.WriteLine("Accepted"); } else { Console.WriteLine("Denied"); } } } } // Try not to follow me
22nd Aug 2022, 3:00 AM
Abdul Bari Rahmani
Abdul Bari Rahmani - avatar
+ 1
Rik Wittkopp Thanks you, I understand it now. The calculation looks much easier like this too
3rd Dec 2021, 11:20 AM
Lena Morawietz
Lena Morawietz - avatar
0
Logical Operators Students should have at least 95% attendance and an average score of 80 to win a scholarship. Write a program to take attendance and average score values as input and output "Accepted", if the given requirements are satisfied, and "Denied", if they are not. Sample Input 98 70 Sample Output Denied Use the && operator to chain the conditions.
1st Jun 2022, 7:08 AM
Mohamed Suleyman Ibrahim
Mohamed Suleyman Ibrahim - avatar
- 1
Lena Morawietz See if this helps. Review it against your recent tutorials in order to understand the concepts foreach(string item in coffee.Keys.ToArray()){ double rebate = (coffee[item]*discount)/100; Console.WriteLine(item +": "+ (coffee[item] - rebate));
3rd Dec 2021, 10:36 AM
Rik Wittkopp
Rik Wittkopp - avatar