>I didn't open any books for over a year
I hate to be the one to say this to you, but I think it's time to seriously reconsider your path in life.
If you're a university student and you're devoting zero hours per week to your studies, you're wasting your time and you're not going to be successful. I'm not sure where you got this expectation that you're going to be competent and proficient without studying or practicing, but you **urgently** need to get this idea out of your head. Whatever lazy habits you picked up in high school are failing you badly now, and the sooner you recognize this the sooner you can change course. Of course you're going to fail if you don't study! You're experiencing the **expected and intended result** of that decision, and you don't get to pretend to be mystified by your poor grades.
If you're so completely lost in every one of your courses that you cannot solve a single problem, you need to take the W. Withdraw - this will limit the damage to your GPA. Then, you need to go back and learn the material from the prerequisites. That base you're describing as "not that strong"? That base is so, so essential. You need to strengthen it before you try again.
If the thought of going back a year (or more...) horrifies you, then look in the mirror and decide if this major is the right place for you.