Loading...

Във форума е въведено ограничение, което позволява на потребителите единствено да разглеждат публикуваните въпроси.

Bojiadar avatar Bojiadar 2 Точки

Google-Searches MidRetake

You will be given several lines of input and you must calculate how much money Google makes from user searchi On the first line, you will receive the Google income from a single search of a user. On the second line you will receive the number of users . On the following n lines, you will get the number of searches each user make. You must calculate the total money from the searches. However, there are some additional rules: If the searches of a user are more than 5, we double the money earned from the searches. If a user makes just one search, we ignore the search and Google did not earn any money from it For each third user, the money per search is tripled O If third user's searches are greater than 5, you should ALSO double the money per search DI Ifthird user make one search, the search should be ignored. After calculating the total money, print them in the following format: "Total money earned: {totalMoney)". The money should be formatted to the second decimal point. Input First line: money per search - floating-point number in range [0.00 - 5000.001. Second line: number of users  - integer in range [0 - 10000]. Next lines: number of searches for each user- integer in range [0 - 10000]. Output Print the output in the format described above. Constraints The command will always be valid.

using System;

namespace _01.FirstExercise
{
    internal class Program
    {
        static void Main(string[] args)
        {
          double moneyPerSearch = double.Parse(Console.ReadLine());
            int numberOfUsers = int.Parse(Console.ReadLine());
            double totalMoney = 0;
            for (int user = 1; user <= numberOfUsers; user++)
            {
                int currentUser = int.Parse(Console.ReadLine());
                if (currentUser == 1 || currentUser <= 0) continue;
                if (!(user % 3 == 0) && (currentUser > 1 && currentUser <= 5)) 
                {
                    totalMoney += moneyPerSearch * currentUser;
                }
                if (currentUser > 5)
                {
                    double moneyEarned = moneyPerSearch * (double)currentUser * 2;
                    totalMoney += moneyEarned;
                }
                if (user % 3 == 0)
                {
                    if (currentUser == 1 || currentUser <= 0) continue;
                    double tripled = moneyPerSearch * 3;
                    if (currentUser > 1 && currentUser <= 5)
                    {
                        tripled *= currentUser;
                        totalMoney += tripled;
                    }
                    if (currentUser > 5)
                    {
                        double @doubeOparation = moneyPerSearch * 2 * numberOfUsers;
                        totalMoney += doubeOparation;
                    }
                }
            }
            Console.WriteLine($"Total money earned: {totalMoney:f2}");
        }
    }
}

Моля за решение! Благодаря предварително!

Тагове:
1
C# Fundamentals
krum_43 avatar krum_43 750 Точки

Hello Bozidar,

В общи линии логиката е вярна,но забелязах някои пропуски:

1) int currentUser = int.Parse(Console.ReadLine());

Явно тук имаш на предвид броя на тьрсения на текущият потребител.

По четимо би било да именуваш променливата

int numberofSearchesofcurrentUser = int.Parse(Console.ReadLine());

2) на този ред:

  double @doubeOparation = moneyPerSearch * 2 * numberOfUsers; дефинираш една променлива а на следващия добавяш друга:

totalMoney += doubeOparation;

Това @ не ти ли чупи кода?

 

 

0
Bojiadar avatar Bojiadar 2 Точки

Не, открих грешката. Благодаря Ви за помоща!

1
krum_43 avatar krum_43 750 Точки

А ти какви точки вземаш с това решение?В системата(Judje) няма задача с такова име.

0
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.