Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Basic Type Conversion | Håndtering af Datatyper
C# Grundlæggende

book Challenge: Basic Type Conversion

Opgave

Swipe to start coding

You will calculate the total weight of an order, including the weight of individual items and their packaging, and then convert the total weight to an integer.

  • Inside the method, calculate the total weight of all items by multiplying the weight of one item by the total number of items.
  • Calculate the total packaging weight by multiplying the packaging weight per item by the total number of items.
  • Add the items' weight and the total packaging weight to get the total order weight.
  • Convert the total weight from a double to an integer using Convert.ToInt32 to show a rounded whole number.
  • Print all relevant information to the console, including the weight of a single item, the packaging weight per item, the number of items, the total weight as a double, and the total weight as an integer.

Løsning

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 19
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

close

book Challenge: Basic Type Conversion

Stryg for at vise menuen

Opgave

Swipe to start coding

You will calculate the total weight of an order, including the weight of individual items and their packaging, and then convert the total weight to an integer.

  • Inside the method, calculate the total weight of all items by multiplying the weight of one item by the total number of items.
  • Calculate the total packaging weight by multiplying the packaging weight per item by the total number of items.
  • Add the items' weight and the total packaging weight to get the total order weight.
  • Convert the total weight from a double to an integer using Convert.ToInt32 to show a rounded whole number.
  • Print all relevant information to the console, including the weight of a single item, the packaging weight per item, the number of items, the total weight as a double, and the total weight as an integer.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 19
single

single

some-alt